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

Re: Bash script problem



On Thu, Aug 05, 2021 at 09:26:35AM +0100, Tixy wrote:
> On Thu, 2021-08-05 at 10:36 +0300, Anssi Saari wrote:
> [...]
> > 
> > [ A="0 ; " ]
> > 
> > is always true. It seems it probably has something to do with expansion,
> > quoting and the special meaning of ;.
> > 
> 
> ; has no special meaning inside "". The expression is true because
> there is only a single non-null argument between the [ ]

Yes, well put. As much as

  [ foobarbazxy ]

is always true :-)

I always recommend `echo' to those who want to "see" argument
expansion before pulling out their hair. Try

  echo A="0 ;  "
  => A=0 ;

Since whitespace is so difficult to see, let's prepend and postpend
something (the `-n' option tells echo to not output a newline):

  echo -n '<' ; echo -n A="0 ;  " ; echo '>'
  => <A=0 ;  >

Cheers
 - t

Attachment: signature.asc
Description: Digital signature


Reply to: