delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2013/08/12/14:23:41

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:to:from:subject:date:message-id:references
:mime-version:content-type; q=dns; s=default; b=fZ1S9jvI/GqoB8gb
alaejabIHNv2/sykyPCSLXOl/YtFxCzvGipEyN+zhQpeREjBlYvKvx3rTizXfurd
7rQc/gcVBjAX6jIU+igw4u8eR1VP06Oyv1Uj20ziHcHTcYG4rUsGFAQ7slTLDfxp
pZyd6jykoeuPnzBe7UNn3rqgfXc=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:to:from:subject:date:message-id:references
:mime-version:content-type; s=default; bh=hGy5/Pb9UStqz2q7seMeRB
l7EHE=; b=cvqvmO5YVjbZOKv3y2ugp+ZN/yyHE2qsO1JtcRjRqg45wAWMGymouL
c6wZ7DqXitP5H/WE5nohQKRcwGx++42bRf9K4AEV86GHpmvNWXXrzddA9ZoZvFJ1
ENBUxP9W6aSMjZ2mv8GWIAyplhqIl6nED985OLTenVt7aYBVXMNKA=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-Spam-SWARE-Status: No, score=-4.7 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_NO,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2
To: cygwin AT cygwin DOT com
From: Achim Gratz <Stromeko AT nexgo DOT de>
Subject: Re: bash ignoring set -f on windows
Date: Mon, 12 Aug 2013 20:23:04 +0200
Lines: 125
Message-ID: <871u5yvkdz.fsf@Rainer.invalid>
References: <CA+t=3-91S0PSp3nYZgrNg9ymzx+9gB=HSTvT6EZznZX2Q=Jrgg AT mail DOT gmail DOT com> <loom DOT 20130812T145113-232 AT post DOT gmane DOT org> <CA+t=3--DJWuNXapE3OVBvngvFAZOKADQJ1LUcSjrJD5bo5-NFQ AT mail DOT gmail DOT com>
Mime-Version: 1.0
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019