[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [leafnode-list] Re: Fetchnews and Shell Script
> if [ "$(ls /var/spool/news/out.going)" = "" ]; then
This will probably work in the specific case of Leafnode, but
in general you should never put a variable value verbatim in
a "[" / "test" conditional. Reason: if the value starts with "-",
"test" will get all confused over what's happening. E.g.
[ -r = "" ]
is a syntax error: it tells "test" to check whether the file
"./=" is readable, but then there's an extra argument that's not valid
at that position.
`...` has existed in shells since The Memory Of Man Runneth Not
To The Contrary, and so it's generally safer to use, and $(...)
is only needed if you want to nest `...` without using a variable.
The "..." shown is indeed needed, because the return value of
ls may have multiple words, and "test" might be confused.
Must go. In short, I'd code it as
if [ x"`ls /var/spool/news/out.going`" = x"" ]; then
--
Tim McDaniel is tmcd@xxxxxxxx; if that fail,
tmcd@xxxxxxxxxx is my work account.
"To join the Clueless Club, send a followup to this message quoting everything
up to and including this sig!" -- Jukka.Korpela@xxxxxx (Jukka Korpela)
h
--
leafnode-list@xxxxxxxxxxxxxxxxxxxxxxxxxxxx -- mailing list for leafnode
To unsubscribe, send mail with "unsubscribe" in the subject to the list