Closed brkerez closed 5 years ago
@brkerez - Sorry for the horribly delayed response but is this still an issue with current unrelease version?
@daxgames still broken, make a directory called "!" and extract cmder into it, vendor/init.bat won't run properly
I just wanted to ressurrect this bug, since I ran into it. Or should I open a new one ?
!
is a special character in bash shell and in cmd.exe. probably not a good idea to creat folders with !
in the and definitly not put them in wnvitonment variables.
It's maybe not a good idea, yet cmnder shouldn't mangle them. cmd.exe deals with them OK and can also use the %PATH%. A user may well be named "Hello!" and then you have it all over the place.
! Expansion is configurable in clink. I think you can disable it completely which is what you are asking for. I just cant remember the exact setting. Cmder is trying to make cmd more like bash by providing this functuonlity as a default.
The majority of people would not have directories with special characters in them as evidenced by the fact that this issue went stale and was closed automatically. We are reluctant to change long standing defaults without overwhelming request to do so.
I don't know clink, so I can't comment on it. Only on bash. Interpreting '!' in environment variables strikes me as a bad idea irregardless. Again: cmd.exe
doesn't mind and works with '!'. Why is clink
authorative and not cmd.exe ?
bash certainly doesn't do it. e.g. foo='x!x'; eval echo "$foo"
-> x!x
. '!' in bash AFAIK is just a repl feature.
OK @mulle-nat I did some looking at this. Sorry was in the car earlier responding via my phone. The reason this is failing is because %cmder_root%\vendor\init.bat
, Cmder's init script, uses a cmd.exe
extension called delayedexpansion
to do some advanced env var operations.
Delayed expansion wraps env vars with !
instead of %
. Env vars wrapped in !
in if
or loop operations are not expanded until the script hits that line. Without delayed expansion Cmder would not be be able to initialize itself.
Your directory has one !
and delayedexpansion
expects them to come in pairs so when Cmder's init.bat
runs it sees it as an opening marker for a delayedexpansion
env variable and when it doesn't find a closing one everything after that is messed up.
delayedexpansion
is a feature of Cmd.exe and is the reason you should not use !
in any component that could be used in a *.bat
or *.cmd
script.
Again don't use special characters like !
in directory names. You would have the same issue running a script that used delayedexpansion
in cmd.exe
that had nothing to do with Cmder
.
I just read this [https://ss64.com/nt/delayedexpansion.html]() and hey, what a crap feature that is. But anyway, I don't know that much about BAT files. I looked at init.bat
. Maybe this helps and maybe it doesn't. It seems that you are "enhancing" the PATH with some stuff. If thats true, you could
I am trying to help you by continuing to looking at this, not having much luck though. Cmd.exe is a crap shell that does a lot of bad stuff so these extensions were developed. The entire reason Cmder exists to try and make more usable. This is a very rare situation.
If you can''t not have an !
in the path then why not just use bash with is afar superior shell anyway.?
My current workaround is, that I moved the corrupted PATH parts to the end of the definitions. But this will bite me in the future again I'm sure.
I could probably just remove the code from vendor\init.bar
or throw all the init code away. Personally I don't need all the nice stuff Cmder offers in the init scripts.
I am running bash inside Cmder :). My setup is, that I run the Visual Studio command line shell, to get the environment variables. Then I start Cmder from within, to get a more sane terminal. And then inside Cmder I am starting WSL and then I am in a bash.
But corrupting the PATH is still wrong IMO, so thats why am writing this.
Using !
in directories in the path is what is wrong. Try this though. It works for me.
You say that it's wrong, but actually the list of characters, that are illegal for a directory name does not contain '!' [https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file](). It's not illegal on Unix either, just inconvenient. I will try your artifact and report.
Looks good to me now.
I noticed that when my user
PATH
environment variable contains some entry with!
, next entry gets corrupted thus executables there are not found then when running from Cmder while they are reachable from classic cmd.Don't know if that's Conemu or Cmder problem, but it seems that when parsing
PATH
, characters following!
till next semicolon (inclusive) get eaten, missing semicolon then causes that next entry is concatenated with preceding broken part and both ends up corrupted and executables are missing fromPATH
in Cmder.Similar, maybe related open issues #1589 , #1650
Example
user
PATH
in cmd (notice the entryc:\Users\501554096\!appdata;
and following entry withc:\Users\501554096\work\scriptsDeploy\;
):Path=C:\development\Ruby25-x64\bin;C:\ProgramData\Oracle\Java\javapath;C:\development\Python27\;C:\development\Python27\Scripts;C:\Oracle\product\11.2.0\client_2\bin;c:\Oracle\instantclient21\;;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\CA\DSM\bin;C:\Program Files (x86)\WinMerge;C:\Program Files (x86)\PuTTY\;C:\Program Files\PuTTY\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\TortoiseHg\;C:\Program Files (x86)\GitExtensions\;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Program Files\TortoiseGit\bin;c:\Users\501554096\!appdata\;c:\Users\501554096\work\scriptsDeploy\;c:\Program Files (x86)\PuTTY\;c:\development\gradle4\bin;c:\development\jarscan\;c:\development\ant\bin\;c:\development\maven\bin\;C:\Users\501554096\AppData\Local\atom\bin;c:\Users\501554096\apps\wget\
PATH
in cmder (!appdata;
gone, both entries combined intoc:\Users\501554096\\Users\501554096\work\scriptsDeploy\;
):Path=C:\Users\501554096\apps\cmder\bin;C:\Users\501554096\apps\cmder\vendor\conemu-maximus5\ConEmu\Scripts;C:\Users\501554096\apps\cmder\vendor\conemu-maximus5;C:\Users\501554096\apps\cmder\vendor\conemu-maximus5\ConEmu;C:\development\Ruby25-x64\bin;C:\ProgramData\Oracle\Java\javapath;C:\development\Python27\;C:\development\Python27\Scripts;C:\Oracle\product\11.2.0\client_2\bin;c:\Oracle\instantclient21\;;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\CA\DSM\bin;C:\Program Files (x86)\WinMerge;C:\Program Files (x86)\PuTTY\;C:\Program Files\PuTTY\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\TortoiseHg\;C:\Program Files (x86)\GitExtensions\;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Program Files\TortoiseGit\bin;c:\Users\501554096\\Users\501554096\work\scriptsDeploy\;c:\Program Files (x86)\PuTTY\;c:\development\gradle4\bin;c:\development\jarscan\;c:\development\ant\bin\;c:\development\gource\;c:\development\maven\bin\;C:\Users\501554096\AppData\Local\atom\bin;c:\Users\501554096\apps\wget\;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\share\vim\vim74;C:\Users\501554096\apps\cmder\
Version
cmder: v1.3.5 os: Windows 7 x64