[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bash syntax




Charles Menzes said:
> if [ -z $HOMEDIR ]; then

From the bash(1) man page:

              -z string
                     True if the length of string is zero.

$HOMEDIR is not zero-length, therefore the if/fi block is skipped.
Perhaps you meant

    if [ ! -d "$HOMEDIR" ]; then

which would test to make sure that the directory did not exist.
(Since mkdir is atomic, you could even do something like

    if mkdir "$HOMEDIR" 2>/dev/null ; then

and get the same effect.)

Also, at least when testing, I recommend doing "set -x" and "set -e"
at the beginning of the script.

Steve
-- 
steve@silug.org           | Linux Users of Central Illinois
(618)398-7320             | Meetings the 4th Tuesday of every month
Steven Pritchard          | http://www.luci.org/ for more info

--
To unsubscribe, send email to majordomo@luci.org with
"unsubscribe luci-discuss" in the body.