This is the mail archive of the
cygwin
mailing list for the Cygwin project.
bash ignoring set -f on windows
- From: Craig Ryan <cryan dot dublin at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Mon, 12 Aug 2013 21:06:42 +1000
- Subject: bash ignoring set -f on windows
The cygwin bash is ignoring noglob on windows 7 and XP. Cygwin
details: CYGWIN_NT-6.1 1.7.17(0.262/5/3) 2012-10-19 14:39
To illustrate, here is a script which calls a java application
which I expect to have wildcards passed through as-is to the java
main String[ ]args. Source to both as follows.
----------------------------
#!/bin/bash
set -f
ARGS=$@
ARGSQ="$@"
# Try both quoted/unquoted ARGS
echo unquoted call to TestApp
$JAVA_HOME/bin/java TestApp $ARGS
echo quoted call to TestApp
$JAVA_HOME/bin/java TestApp $ARGSQ
-----------------------------
The java app is simply:
public class TestApp {
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("WRONG!! NO ARGS AT ALL - should be '*'");
return;
}
if (args[0].equals("*")) {
System.out.println("GOT '*'!!");
} else {
System.out.println("WRONG!! got '" + args[0] + "' - should be '*'");
}
}
}
From a cygwin terminal, cd to the directory containing the java
source and script. Compile the app and run as follows
$ javac TestApp.java
$ ./bash.sh ‘*’
That’s asterix in single quotes. I expect to see
GOT '*'!!
But I get
WRONG!! got 'bash.sh’ – should be ‘*’
The ‘set –f’ in the script is ignored and therefore wildcard
expansion is enabled for the java invocation. If I comment out
‘set –f’ the result is the same.
If I run the same test on a Mac the result is that with ‘set –f’
uncommented no wildcard expansion occurs and with ‘set –f’ active
expansion does occur as expected.
I am shipping a similar script with my open source app so I need
to instruct users the easiest way to fix this just for cygwin.
Is this a known problem? Can you please outline what the
issue/bug/limitation is, and the least impact fix a user can be
expected to cope with please?
The following isn't reasonable to expect from users:
- Full scale cygwin version upgrades (a few file updates are OK)
- Any requirement to build any cygwin or other software from source
- Having to set a global or environment setting which affects
software other than my app
I can live with workarounds within my own script (bash.sh above)
so long as it works in non-cygwin shells.
I’d really appreciate help on this.
thanks,
Craig
--
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