bmatzelle / gow

Unix command line utilities installer for Windows.
https://github.com/bmatzelle/gow/wiki
6.58k stars 365 forks source link

bash breaks Windows tools by replacing forward slash with a directory path #196

Open alisonatwork opened 9 years ago

alisonatwork commented 9 years ago

It seems like bash is searching through all arguments you give on the command line and prefixing anything that starts with / with Gow's own fake root directory. Personally i have not seen any real-world use for this "feature", though perhaps it is doing it so that shell script references to stuff like /etc works. Unfortunately it makes pretty much all Windows command line tools unusable from the shell:

bash-3.1$ tasklist /?
FEHLER: Argument/Option ungültig - "C:/Program Files (x86)/Gow/?".
Geben Sie "TASKLIST /?" ein, um die Syntax anzuzeigen.
bash-3.1$ tasklist '/?'
FEHLER: Argument/Option ungültig - "C:/Program Files (x86)/Gow/?".
Geben Sie "TASKLIST /?" ein, um die Syntax anzuzeigen.
bash-3.1$ tasklist '\/?'
FEHLER: Argument/Option ungültig - "\/?".
Geben Sie "TASKLIST /?" ein, um die Syntax anzuzeigen.
bash-3.1$ tasklist \/?
FEHLER: Argument/Option ungültig - "C:/Program Files (x86)/Gow/?".
Geben Sie "TASKLIST /?" ein, um die Syntax anzuzeigen.

As you can see, quoting or backslashing does not solve the problem. I would like some kind of switch to turn this behavior off, in particular for interactive shell (not in scripts).

stlee987 commented 8 years ago

In general, putting two forward slashes is the solution. Therefore, this works.

$ tasklist //?
TASKLIST [/S system [/U username [/P [password]]]]
         [/M [module] | /SVC | /V] [/FI filter] [/FO format] [/NH]
...

This is what is called POSIX path conversion and is documented at http://www.mingw.org/wiki/Posix_path_conversion.

Unfortunately, I am running into a corner case where I am unable to resolve this problem.

rsync -rvztn --delete --exclude="/application/logs/" ...

I don't want the --exclude parameter to include the Gow root directory, but adding an extra leading '/' won't work either because when there is another slash in the path (e.g. /logs), then it won't remove one of the leading slashes according to the POSIX path conversion rules.

199sm commented 5 years ago

//application\logs\ should to work in this way

AuthorProxy commented 4 years ago

the same, cannot use variable with forward slash

TheDark commented 3 years ago

FWIW, I am using an XPath value as an argument. I managed to bypass the replacement by quoting the argument and adding a space before the forward slash: " /Product/Description"

oldpink commented 3 years ago

FWIW, I am using an XPath value as an argument. I managed to bypass the replacement by quoting the argument and adding a space before the forward slash: " /Product/Description"

Excellent! I was looking at having to radically rewrite all of my existing bash scripts that I use across both Linux and Windows platforms to use a totally different delimiter, but your little elegant trick makes it as easy as inserting a single space before all commands that use the forward slash. Thank you.