[plug] Shell Scripting Confusion

Garth Atkinson garth at cclinic.com.au
Wed Feb 9 14:08:27 WST 2000


Christian wrote:
> 
> Mike Holland wrote:
> >
> > On Wed, 9 Feb 2000, Christian wrote:
> 
> > When you see the answer you'll want to stick with perl.
> > Shell programming is ugly.
> 
> Well, I do really want to stick with Perl but I'm hacking one of the
> scripts on the system so while it's very tempting to just do "perl -e
> '<insert nice, sensible, sane code in here>'", it doesn't look that good
> really, does it? :-)
> 
> > > if [ -n $output ]; then
> >
> > Since $output is empty, that evaluates as  "if [ -n ]; then "
> > which ought to at least give an error message?
> >
> > Try:
> >         if [ -n "$output" ]; then
> >
> > I'll bet you're groaning by now.
> 
> Hmmm... yeah, a little... but why does $output evaluate to being empty
> whereas "$output" has meaning?  Is it that you require the quotes to
> actually turn it into a string?
> 
> Thanks for your help,
> 
> Christian.
Hi Christan

Another alternative would be (might make more sense):

if [ -n ${output}"" ] ; then



Garth



More information about the plug mailing list