[u-u] Sams book

D. Hugh Redelmeier hugh at mimosa.com
Fri Jan 15 15:25:57 EST 2016

| From: Jim Mercer <jim at reptiles.org>

| -e completely changes the way the shell runs, and i highly suggest never
| enabling it.
| for example, if you have anything like
| #! /bin/sh
| someprog -a -b -c
| if [ $? -ne 0 ] ; then
|    take some action
| fi

More clearly written as:
	someprog -a -b -c || take some action
	if ! someprog -a -b -c ; then
		take some action

And these are faster on the original Bourne shell (where [ was not a builtin).

| it totally will not do what you think.

I agree that it is a change in how one thinks.  A good one.

| i lost a chunk of hair trying to figure out why a script were failing
| silently, then discovered that someone had put in "#! /bin/bash -e"

I like to be able to say "bash -x scriptname" so putting the flag in
the shebang is not appropriate.

| also, if you are writing a bash script, start with #! /bin/bash,
| even if your system errantly installs bash as /bin/sh


| bash != bourne shell


More information about the u-u mailing list