Why parse lines with colons - (nf)
dan at haddock.UUCP
dan at haddock.UUCP
Wed Jul 18 13:45:04 AEST 1984
#R:spuxll:-52600:haddock:16800020:000:593
haddock!dan Jul 16 13:59:00 1984
> One of the reasons /bin/sh (bsh to those who like csh)
> parses lines with ":" in the beginning is because of
> constructs like the following:
> : ${FOO:-default}
I think you mean
: ${FOO:=default}
> This effectively sets $FOO to a default value if not previously
> set. The longhand way would be:
> if [ "${FOO}" = "" ]
> then
> FOO=default
> fi
No, the "longhand" way would be
FOO=${FOO:-default}
which isn't very much longer, and has the advantage that it works even if you
set -u (which I usually do). I don't think this is a good reason to parse
lines with ":".
Dan Franklin
More information about the Comp.unix.wizards
mailing list