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: bash ignoring set -f on windows


Craig Ryan writes:
>> I think putting the blame on bash is premature.  Try replacing the call to
>> java with a script of your own to see what arguments it get called with,
>
> How so? This works on un*x platforms so what am I missing?

You are missing that Windows is not Un*x.  On Windows, each application
is expected to do their own globbing (if it cares to do it at all),
since cmd doesn't do that.

> The script IS my own, if you execute the script as suggested what
> results did you get with cygwin/windows?

I can't run your script since you didn't say how you call it or what the
version of Java is that you were using.  I did point out that while you
were looking at bash, you ignored the fact that Java itself would
attempt to expand glob characters.

But you can make a new empty directory, put these two files in there:

--8<---------------cut here---------------start------------->8---
#!/bin/bash
# this is t1.sh
set -f
ARGS=$@
ARGQ="$@"
echo "noglob/unquoted/unquoted:" $ARGS
./t2.sh "-->"  $ARGS  "<--"
echo "noglob/quoted/unquoted:  " $ARGQ
./t2.sh "-->"  $ARGQ  "<--"
echo "noglob/unquoted/quoted:  $ARGS"
./t2.sh "-->" "$ARGS" "<--"
echo "noglob/quoted/quoted:    $ARGQ"
./t2.sh "-->" "$ARGQ" "<--"
set +f
echo "  glob/unquoted/unquoted:" $ARGS
./t2.sh "-->"  $ARGS  "<--"
echo "  glob/quoted/unquoted:  " $ARGQ
./t2.sh "-->"  $ARGQ  "<--"
echo "  glob/unquoted/quoted:  $ARGS"
./t2.sh "-->" "$ARGS" "<--"
echo "  glob/quoted/quoted:    $ARGQ"
./t2.sh "-->" "$ARGQ" "<--"
--8<---------------cut here---------------end--------------->8---

--8<---------------cut here---------------start------------->8---
#!/bin/bash
# this is t2.sh
set -f
echo "  ==>  noglob/unquoted: " $@
echo "  ==>  noglob/quoted:    $@"
set +f
echo "  ==>    glob/unquoted: " $@
echo "  ==>    glob/quoted:    $@"
--8<---------------cut here---------------end--------------->8---

make them both executable and then run t1.sh.  This should produce the
following output:

--8<---------------cut here---------------start------------->8---
$ ./t1.sh "*"
noglob/unquoted/unquoted: *
  ==>  noglob/unquoted:  --> * <--
  ==>  noglob/quoted:    --> * <--
  ==>    glob/unquoted:  --> t1.sh t2.sh <--
  ==>    glob/quoted:    --> * <--
noglob/quoted/unquoted:   *
  ==>  noglob/unquoted:  --> * <--
  ==>  noglob/quoted:    --> * <--
  ==>    glob/unquoted:  --> t1.sh t2.sh <--
  ==>    glob/quoted:    --> * <--
noglob/unquoted/quoted:  *
  ==>  noglob/unquoted:  --> * <--
  ==>  noglob/quoted:    --> * <--
  ==>    glob/unquoted:  --> t1.sh t2.sh <--
  ==>    glob/quoted:    --> * <--
noglob/quoted/quoted:    *
  ==>  noglob/unquoted:  --> * <--
  ==>  noglob/quoted:    --> * <--
  ==>    glob/unquoted:  --> t1.sh t2.sh <--
  ==>    glob/quoted:    --> * <--
  glob/unquoted/unquoted: t1.sh t2.sh
  ==>  noglob/unquoted:  --> t1.sh t2.sh <--
  ==>  noglob/quoted:    --> t1.sh t2.sh <--
  ==>    glob/unquoted:  --> t1.sh t2.sh <--
  ==>    glob/quoted:    --> t1.sh t2.sh <--
  glob/quoted/unquoted:   t1.sh t2.sh
  ==>  noglob/unquoted:  --> t1.sh t2.sh <--
  ==>  noglob/quoted:    --> t1.sh t2.sh <--
  ==>    glob/unquoted:  --> t1.sh t2.sh <--
  ==>    glob/quoted:    --> t1.sh t2.sh <--
  glob/unquoted/quoted:  *
  ==>  noglob/unquoted:  --> * <--
  ==>  noglob/quoted:    --> * <--
  ==>    glob/unquoted:  --> t1.sh t2.sh <--
  ==>    glob/quoted:    --> * <--
  glob/quoted/quoted:    *
  ==>  noglob/unquoted:  --> * <--
  ==>  noglob/quoted:    --> * <--
  ==>    glob/unquoted:  --> t1.sh t2.sh <--
  ==>    glob/quoted:    --> * <--
--8<---------------cut here---------------end--------------->8---

> I read this, I'm not sure what it provides as a solution? Apart from
> the fact that I dont require java 7, what is the expected cygwin bash
> glob behaviour?

Maybe the above example convinces you that bash does respect the noglob
switch, even on Cygwin.

What Java does when it gets a command line with a globbing character is
a different matter.  It seems that it expects the glob character inside
quotes or even quoted quotes, depending on version.  Note that the
outermost quotes will be removed by bash before Java gets to see it, so
you will have to do something like "\"$@\"" or even "\\\"$@\\\"" to get
this construct onto the commandline of Java unharmed.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Waldorf MIDI Implementation & additional documentation:
http://Synth.Stromeko.net/Downloads.html#WaldorfDocs


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


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