Andrew Lentvorski wrote:
> John H. Robinson, IV wrote:
> >Menachem Shapiro wrote:
> >>I came across this site that lists some common Bash pitfalls, as well
> >>as the correct way of doing things:
> >>http://wooledge.org/mywiki/BashPitfalls
> >
> >Top 4 reasons why zsh is better than bash:
>
> Which demonstrates yet again why you shouldn't actually use a pure
> scripting language for anything other than the most basic boot scripts.
>
> If pure Bourne shell isn't good enough, then you need to step up to at
> least Perl.
The following affect sh:
1. for i in `ls *.mp3`
2. cp $file $target
3. [ $foo = "bar" ]
4. cd `dirname "$f"`
5. [ "$foo" = bar && "$bar" = foo ]
8. if [grep foo myfile]
9. if [bar="$foo"]
10. if [ [ a = b ] && [ c = d ] ]
11. cat file | sed s/foo/bar/ > file
12. echo $foo
13. $foo=bar
14. foo = bar
15. echo <<EOF
16. su -c 'some command'
17. cd /foo; bar
18. [ bar == "$foo" ]
19. for i in {1..10}; do ./something &; done
Basically, everything except 6 and 7. 6 used [[ ]], and 7 used (( )),
which are bashisms. Like most bashisms, they are still legal when bash
is invoked as sh.
We could almost change the title sh Pitfalls, and lose little content.
But then I would have missed my opportunity to pimp my favourite $SHELL.
I do agree that when you have to reach for the *advanced* features of a
shell, it is time to look at a real scripting language, like perl.
I do use those advanced features of the shell all the time,
interactively. They are good to know, and good to know how to use.
-john
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list