Re: C5 BASH IF

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Fri, Feb 13, 2015 at 11:54 PM, Always Learning <centos@xxxxxxxxxxx> wrote:
>
>> And third, you generally should use
>> double quotes around variables in tests so they continue to exist as
>> an empty string if the variable happens to not be set.
>
> Thanks for that.  I assumed if test 1 worked, so would test 2.
>
> Have re-run test 2 with
>
>
>> 16 if  [ $file = "law00css" ]

You still missed the part about quoting variables.  You quote plain
strings to hold embedded spaces together (or single-quotes to avoid
parsing metacharacters).  You use double quotes around  $variables so
they don't disappear completely if the variable isn't set, causing a
syntax error.  To understand it completely you need to know the order
of operations as the shell makes multiple passes over the line,
parsing, processing metacharacters, and expanding variables.   And I
don't know where to find a concise description of that any more.

-- 
   Les Mikesell
     lesmikesell@xxxxxxxxx
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos




[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux