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 [


Eric Blake sent the following at Tuesday, December 17, 2013 11:08 PM
>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.

In my original post, I should have reported that it is a bash script.

>> ./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?

clip

>> I fixed it with this.
>>
>> if [ "x$1" = xclip ]
>
>Yes, this is the correct fix for the improper quotation of the earlier
>example.

But why would it need quoting unless the first argument unless the
command line is quoted and might have a space"?  It wasn't.  It was
called from a script that was being sourced by a bash interactive shell
as follows.

lddir clip

"clip is telling lddir to get its input from the clipboard instead of
the command line.  "clip" is never used with another argument.  The
calling script is being sourced because it is change the working
directory of the interactive shell.  And the path of that directory
is known to not have spaces.

>> 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 [.

For that, it would have to be called with $1 on the command line in
quotes, which it wasn't.  Something like the following.

lddir "111 one" 222 "three 333" 444

And then there's the fact that I've been using lddir with no changes
for the past year and it just started misbehaving now.

Speculation:  Since cygwin1.dll was updated last week, perhaps
something happened there.  But if no one else reports a similar
problem, it might be something peculiar to my installation and use
and not worth debugging.

Thanks for your response.

- Barry
  Disclaimer: Statements made herein are not made on behalf of NIAID.


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