I've often heard people say that you should use #!/bin/sh in your shell scripts to ensure they run everywhere.
I always use /bin/bash - because I like the bash-specific features and wouldn't like to live without, and I don't have a list in hand that shows me which "features" I can't use if using /bin/sh - so I can't be sure my script actually works on generic /bin/sh - without testing.
What do I mean without testing? If I use bash-specific features (like $!VAR ) they still work, as long as /bin/sh is actually using bash, even though it is my understanding that bash should emulate the sh posix standard, it obviously extends it. This is a major bummer, as my script breaks if I accidently use some bash-specific feature.
I recently saw this, on some Linux distro's that use dash to emulate /bin/sh - and it does not support the $!VAR notion from bash, among other things (I had, by mistake, put #!/bin/sh in the script).
If you use /bin/sh - how do you make sure, you only use the actually supported features - do you have a testbed, or a list of "no-no's" ?
I am a self-employed Open Source, Network and Security consultant - my company is called
Tue, 06/02/2009 - 11:53
Tue, 06/02/2009 - 10:09
Tue, 06/02/2009 - 09:24