Cmder: Create alias with equal sign gets truncated in cmder cli

Created on 2 Feb 2017  ·  3Comments  ·  Source: cmderdev/cmder

Hey there as per title, when I try in cmder prompt to create an alias with an equal sign, what comes with the = gets truncated and not correctly stored in the user-aliases.cmd file.

For ex:
λ alias wifi=netsh wlan show profile $1 key=clear
will be stored as:
wifi=netsh wlan show profile $1 ke

I guess for $reasons cmder reads y=clear as $something worthy evaluating and so it's cut off from the actual alias storing process. Manually editing the file quickly overcome this issue.

Am I blatantly missing something on the ever growing Effin' Manual that I haven't accurately read? 😛

Most helpful comment

It looks like the doskey command (which alias wraps) handles your example, so this may be a bug in the alias.bat script.

You can debug by modifying alias.bat and changing the first line to @echo on. Looking at it now, I see that there is a point where the script splits the alias string using "=" as a delimiter, and assumes that there will only be one = in the string.

Here's a fix: in alias.bat, find the linethat says ":: validate alias" and in the following line replace the '2' with a '*', like so:

for /f "delims== tokens=1,* usebackq" %%G in (echo "%_x%") do (

This seems to work for me with your example.

All 3 comments

It looks like the doskey command (which alias wraps) handles your example, so this may be a bug in the alias.bat script.

You can debug by modifying alias.bat and changing the first line to @echo on. Looking at it now, I see that there is a point where the script splits the alias string using "=" as a delimiter, and assumes that there will only be one = in the string.

Here's a fix: in alias.bat, find the linethat says ":: validate alias" and in the following line replace the '2' with a '*', like so:

for /f "delims== tokens=1,* usebackq" %%G in (echo "%_x%") do (

This seems to work for me with your example.

Thank you for explaining in detail the issue at hand, very useful for me as I'm a novice in CMD stuff! :)
I can confirm your correction fixed the problem, thank you! Should I do a PR?

I can create a pull request with the fix. Thanks for confirming that it works for you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

justinmchase picture justinmchase  ·  3Comments

brunowego picture brunowego  ·  3Comments

hugomrdias picture hugomrdias  ·  4Comments

edgariscoding picture edgariscoding  ·  3Comments

AaronKaa picture AaronKaa  ·  3Comments