Re:Two simple tricks for better shell script error handling
by imurray on Monday April 05, 2010 @10:04AM
(#1241922)
I agree with using /bin/bash if that's what you're actually using and aren't sure the script will work more generally.
Something that can help pin down usage of bash extensions is checkbashisms (in the devscripts package on Debian systems). Also running the script through a shell that claims POSIX compliance like /bin/dash.
Re:Two simple tricks for better shell script error handling
by KC8ZKF on Monday April 05, 2010 @11:37AM
(#1242124)
When invoked as sh, Bash enters POSIX mode after reading the startup files.
Re:Two simple tricks for better shell script error handling
by imurray on Monday April 05, 2010 @01:21PM
(#1242403)
When invoked that way it still supports more than /bin/dash on my system:
% ln -s /bin/bash sh
% ./sh
sh-3.2$ echo {1..10}
1 2 3 4 5 6 7 8 9 10
sh-3.2$ exit
% dash
$ echo {1..10}
{1..10}
where dash is supposed to be POSIX compliant.
OTOH, I believe the error handling tricks discussed should work with any POSIX shell so I've updated the shebang line in the code snippets to use the more generic #!/bin/sh.