Re: passing arguments with getopts



On 2007-03-29, Seb wrote:
On Thu, 29 Mar 2007 18:48:44 GMT,
Seb <spluque@xxxxxxxxx> wrote:

[...]

How can I test later for the existence of VAR2 and pass this to the
external function? I tried:

if [ $VAR2 ] ; then

[...]

Never mind, $VAR2 needed to be double-quoted above.

Safer is to use -n:

if [ -n "$VAR2" ] ; then

--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell/>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
.