From: Oleg Goldshmidt (pub_at_nonexisting.hamakor.org.il)
Date: Tue 24 Jan 2006 - 20:31:01 IST
hareldvd_at_ergolight-sw.com writes:
> Hi all,
>
> In order to avoid using undefined variables one can use the syntax:
> echo ${badvarname:?} which will result in error message would the
> variable be bad (not "defined" or empty). This kind of reference is
> tedious therefore one could use ksh -u (in a script)
> #!/bin/ksh -u
>
> the result is a check upon all variable references, which brings in a new
> problem.
>
> while ($1)
Did you mean,
while test $1
?
> do
> some stuff with $1
> shift
> done
>
> is there a solution for such a case?
Yes, use ${badvarname:?} where appropriate...
Your question seems contradictory to me: on the one hand, you want to
exit the shell if *any* of the variables you use is unset. On the
other hand, in your example your logic *relies* on a variable being
not set.
-- Oleg Goldshmidt | pub_at_NOSPAM.goldshmidt.org | http://www.goldshmidt.org ================================================================= To unsubscribe, send mail to linux-il-request_at_linux.org.il with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail linux-il-request_at_linux.org.il
This archive was generated by hypermail 2.1.7 : Tue 24 Jan 2006 - 20:41:29 IST