11

I'd like to avoid installing bash on every new Debian 6 install. So I need to convert all my bash scripts to dash.
- How would you do that ?
- What are the differences between the 2 languages ?
- Are you aware of any caveat and pitfall ?
- Is it possible to automate that task ?

dugres
  • 12,613
  • 8
  • 46
  • 51
  • This largly depends on your scripts, have you used loads of bash-specific trickery? – plundra Jan 21 '11 at 14:18
  • Slightly tongue-in-cheek (s/slightly/completely/). Go back in time and make sure all of your bash scripts are portable sh. Make sure all future bash scripts are written in sh. Automating it will be extremely difficult, expecially if you've used a lot of bashisms. – William Pursell Jan 21 '11 at 14:38

2 Answers2

8

Here is a page that shows some Bashisms. You can use it as a guide for porting from Bash to Dash.

I don't know why you say you need to install Bash. It's listed as an essential package.

Dennis Williamson
  • 346,391
  • 90
  • 374
  • 439
  • - thanks for the link, that's the kind of doc I'm looking for. – dugres Jan 21 '11 at 23:00
  • - I understood that dash will be installed instead of bash. Will they be both present in the default install ? – dugres Jan 21 '11 at 23:02
  • @dugres: Yes, they both will be installed. While portability and standards compliance has its advantages, so does the ability to use the extra features of a language with more capabilities. – Dennis Williamson Jan 22 '11 at 00:44
  • Cool, so I think that I'm gonna stick to bash for existing scripts and try dash for new ones. – dugres Jan 22 '11 at 09:40
6

The best strategy is to stick to the standard instead of any particular implementation. Dash is much closer to it than Bash.

You might try Loker to get some assistance. If you are interested in it or have any problems, feel free to bother me by email.

There are some other tools as well.

Roman Cheplyaka
  • 37,738
  • 7
  • 72
  • 121
  • yes, I'd like to stick to the standard, but I'm not sure of what feature of bash is standard and which is not, and might not work with dash. – dugres Jan 21 '11 at 22:59
  • @dugres: sorry, perhaps I was not clear. You can either read the specification to find out which features are standard, or you can check your scripts with the tools linked above. They will try to tell you whether a particular script is standard-compliant. – Roman Cheplyaka Jan 22 '11 at 08:37
  • thanks, I'm gonna try this tools. – dugres Jan 22 '11 at 09:37
  • Unfortunately those links are no longer valid. I did find https://github.com/bohdan/loker which hasn't been updated in years. There are some slightly newer forks: https://github.com/alogic0/loker/network/members – spiralofhope Nov 19 '18 at 18:39