This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Change in behavior of bash / if [


On 12/17/2013 08:02 PM, Buchbinder, Barry (NIH/NIAID) [E] wrote:
> Today, a script that I use every day stated giving me the following
> error message.  (I grant that it might have started earlier and I
> didn't notice.)  Note that although it gave the error message, the
> script seems to still have worked.
> 
> ./lddir: line 77: [: too many arguments
> 
> Line 77 was as follows.  I'm testing whether $1 is "clip".
> 
> if [ x$1 = xclip ]

What was $1 at the time?

> 
> I fixed it with this.
> 
> if [ "x$1" = xclip ]

Yes, this is the correct fix for the improper quotation of the earlier
example.

> 
> 32-bit, everything was up to date.
> 
> I've solved my problem, but the change was unexpected and, for me,
> inexplicable, so I thought that I'd report it.

Your quoting error would produce the same message on Linux; it is not
cygwin-specific.

> 
> Let me know if you want/need more information.

Without knowing how $1 was set, I can only guess that it contained
something with characters in $IFS and therefore the word-splitting of
the unquoted use caused too many arguments to [.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]