[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
"[ -n ${emptyvariable} ]" returns success
From: |
jik |
Subject: |
"[ -n ${emptyvariable} ]" returns success |
Date: |
Thu, 20 Sep 2007 15:34:39 -0400 |
Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i386'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-redhat-linux-gnu'
-DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL
-DHAVE_CONFIG_H -I. -I. -I./include -I./lib -D_GNU_SOURCE
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic
-fasynchronous-unwind-tables
uname output: Linux jik2.kamens.brookline.ma.us 2.6.22.5-71.fc7 #1 SMP Fri Aug
24 23:50:35 EDT 2007 i686 i686 i386 GNU/Linux
Machine Type: i386-redhat-linux-gnu
Bash Version: 3.2
Patch Level: 25
Release Status: release
Description:
foo=
[ -n ${foo} ] && echo true
Prints "true".
Should probably print an error, since after the command is
expanded there are only three arguments, so the final ] should
be interpreted as the argument to -n, thus leaving the command
with a missing ] terminator.
Alternatively, if you want to be forgiving and allow the shell
to realize that there was an empty variable before the ], then
the command should return false, since the variable is empty.
Repeat-By:
See above.
- "[ -n ${emptyvariable} ]" returns success,
jik <=