[plug] Shell Scripting Confusion

Chris Griffin chrisg at doladns.dola.wa.gov.au
Wed Feb 9 13:56:42 WST 2000


Because when $output is empty (null) it evaluates to: "if [ -n ]; then " as 
Mike showed.
But when you put the quotes around it, it correctly evaluates to:

"if [ -n ""]; then "

Regards,
Chris


At 05:26 9/02/2000 +0000, you 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.

                               \\\___///
                               \\  - -  //
                                (  @ @  )
+----------------------------oOOo-(_)-oOOo--------------+
| Chris Griffin, Senior Network Engineer                |
| Email: chris.griffin at mitswa.com.au                    |
| Managed Information Technology Solutions (M.I.T.S)    |
| 1st Floor, Batholomew House, 31 Ventnor Avenue,       |
| West Perth W.A. 6005                                  |
| PH: +61 (08) 9481-4066  FAX: +61 (08) 9481-4064       |
+-----------------------------------Oooo----------------+
I haven't lost my mind -     oooO   (   )
- it's backed up on tape    (   )    ) /
   somewhere.                 \ (    (_/
                               \_)




More information about the plug mailing list