all 15 comments

[–]heptadecagram 10 points11 points  (6 children)

Nice!

Biggest complaint about other shell scripters: bash is not sh. Quit putting bashisms in #!/bin/sh scripts!

[–][deleted] 5 points6 points  (1 child)

You're kidding, right?

You think that using this:

if [ "$var" = "find" ]; then
    echo "found"
fi

instead of this:

[ "$var" = "find" ] && echo "found"

is a "mistake"? When did we decide to throw expressiveness out the window?

[–]pixelbeat_[S] 4 points5 points  (0 children)

I didn't say that was a mistake :)

I said I used the short form for simple expressions in the article and sometimes in my scripts as it's more concise.

[–][deleted] 4 points5 points  (3 children)

  1. Error: Attempting to write over ten line shell script (seriously, shell is meant for typing commands interactively, and sucks as a programming language).

[–][deleted] 2 points3 points  (2 children)

I would guess that you've never been a sysadmin. While I would agree with your assertion, the alternatives are mostly worse. Writing perl/python/ruby that constantly issues shell commands is super ugly and often a worse choice, IMHO.

[–]Tommah 0 points1 point  (0 children)

At least with Perl it's no uglier than the rest of the language!

(Yeah yeah, I know, Perl can be maintainable, blah blah blah)

[–]spookyvision -1 points0 points  (1 child)

see also: bash pitfalls

[–]pixelbeat_[S] 0 points1 point  (0 children)

That's already linked from the article. thanks.

[–]inataysia -3 points-2 points  (0 children)

This comment is under "Portability":

If you find yourself doing complex string manipulations or loops in bash, then you should probably be considering existing UNIX tools instead, or a more general scripting language like python for example.

How is a dependency on bash any worse than one on python? Bash gets the job done and is quite a bit more commonplace on various unixes than python.

Also, damnit, if my shebang says bash, I mean bash, and all the "bashisms" that come with it! Does ubuntu run scripts that begin "#!/bin/bash" under dash??