Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to parse path in PATH system variable with '&' #185

Closed
Lopson opened this issue Apr 22, 2014 · 7 comments
Closed

Fails to parse path in PATH system variable with '&' #185

Lopson opened this issue Apr 22, 2014 · 7 comments
Assignees
Milestone

Comments

@Lopson
Copy link

Lopson commented Apr 22, 2014

I have a path in my PATH system variable that contains the character '&' in it. For some reason, whenever cmder starts up, he throws a "The system cannot find the path specified" error when it tries to handle that path.

Here's the content of the PATH variable (output of cmd.exe):
PATH=C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Toshiba\Bluetooth Toshiba Stack\sys;C:\Program Files (x86)\Toshiba\Bluetooth Toshiba Stack\sys\x64;C:\WinDDK\7600.16385.1\Tools\devcon\amd64;C:\Yap64\bin;c:\go\bin;C:\Program Files (x86)\ECLiPSe 6.0\lib\i386_nt;C:\Program Files (x86)\MiKTeX 2.9\miktex\bin;C:\Program Files (x86)\Video & Audio\MKVtoolnix;C:\Python27;C:\Program Files (x86)\Android\android-sdk\platform-tools;C:\Program Files (x86)\GnuPG\pub;C:\Program Files (x86)\Dig;C:\Program Files (x86)\Video & Audio\Quicktime\QTSystem;C:\Program Files (x86)\GTK2-Runtime\bin;C:\Program Files (
x86)\Nmap

And here's what cmder is printing out:
PATH=C:\cmder\vendor\conemu-maximus5\ConEmu;C:\cmder\vendor\conemu-maximus5;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Toshiba\Bluetooth Toshiba Stack\sys;C:\Program Files (x86)\Toshiba\Bluetooth Toshiba Stack\sys\x64;C:\WinDDK\7600.16385.1\Tools\devcon\amd64;C:\Yap64\bin;c:\go\bin;C:\Program Files (x86)\ECLiPSe 6.0\lib\i386_nt;C:\Program Files (x86)\MiKTeX 2.9\miktex\bin;C:\Program Files (x86)\Video

Notice how the last one stops at the '&' character.

@MartiUK MartiUK added this to the 1.1.4 milestone Apr 22, 2014
@MartiUK MartiUK self-assigned this Apr 22, 2014
@MartiUK
Copy link
Member

MartiUK commented Apr 22, 2014

This is due to the init script not handling ampersands correctly:

https://github.com/bliker/cmder/blob/master/vendor/init.bat#L27

We will probably need to change how we set up the PATH in the init script.

For now try adding a '^' before the '&' in you PATH, let me know if that works?

@Lopson
Copy link
Author

Lopson commented Apr 23, 2014

Adding '^' before '&' does work for cmder, but cmd doesn't seem to like it at all, the latter refusing to include the paths with the '^' added into them. Thanks for the help.

@ebelew
Copy link

ebelew commented May 9, 2014

http://stackoverflow.com/questions/4087695/escaping-ampersands-in-windows-batch-files appears to have the answer. You can use delayed expansion.

setlocal EnableDelayedExpansion
set "var=%~1"
echo !var!

@MartiUK
Copy link
Member

MartiUK commented Aug 26, 2014

DelayedExpansion doesn't really work unfortunately, I would suggest wrapping directories with ampersands with double quotes.

@MartiUK MartiUK closed this as completed Aug 26, 2014
@r1m
Copy link

r1m commented Oct 5, 2015

I know this issue is closed. But I managed to work around this by changing init.bat file to this :

:: Enhance Path
@setlocal
@for %%G in ("%path:;=" "%") do @call set "TMPPATH=%%TMPPATH%%;%%G"
@set PATH=%CMDER_ROOT%\bin%TMPPATH%;%CMDER_ROOT%
@endlocal

I had the problem with "MySQL Fabric 1.5.4 & MySQL Utilities" in my path.

@kfrederix
Copy link

I had the exact same problem with "MySQL Fabric 1.5.4 & MySQL Utilities 1.5.4 1.5" in PATH.
For me, this simple fix did the trick:
(just put double quotes around the whole thing in cmder/vendor/init.bat)

:: Enhance Path
@set "PATH=%CMDER_ROOT%\bin;%PATH%;%CMDER_ROOT%"

@jarst
Copy link

jarst commented Mar 16, 2016

How about third party batch files that manipulate PATH?
Unless I patch them, one by one, I will see the same warning whenever I execute them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants