Skip to content

Commit

Permalink
Fix alias.bat handling "user-aliases.cmd" with spaces (#1531)
Browse files Browse the repository at this point in the history
* Fix alias.bat handling "user-aliases.cmd" with spaces

This fixes the alias command when user-aliases.cmd is located in a path with spaces (like when Cmder is installed into the program-files directory).
I've also made the alphabetical case of the ALIASES variable consistent.

* address review comments
  • Loading branch information
Varriount authored and Stanzilla committed Jan 9, 2018
1 parent 724930d commit 3bf07c0
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions bin/alias.bat
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@echo off


if "%aliases%" == "" (
set ALIASES=%CMDER_ROOT%\config\user-aliases.cmd
if "%ALIASES%" == "" (
set ALIASES="%CMDER_ROOT%\config\user-aliases.cmd"
)

setlocal enabledelayedexpansion
Expand All @@ -21,7 +21,7 @@ goto parseargument
set currentarg=%~1

if /i "%currentarg%" equ "/f" (
set aliases=%~2
set ALIASES=%~2
shift
goto :do_shift
) else if /i "%currentarg%" == "/reload" (
Expand Down Expand Up @@ -50,16 +50,16 @@ goto parseargument
)
rem #endregion parseargument

if "%aliases%" neq "%CMDER_ROOT%\config\user-aliases.cmd" (
set _x=!_x:/f %aliases% =!
if "%ALIASES%" neq "%CMDER_ROOT%\config\user-aliases.cmd" (
set _x=!_x:/f "%ALIASES%" =!

if not exist "%aliases%" (
echo ;= @echo off>"%aliases%"
echo ;= rem Call DOSKEY and use this file as the macrofile>>"%aliases%"
echo ;= %%SystemRoot%%\system32\doskey /listsize=1000 /macrofile=%%0%%>>"%aliases%"
echo ;= rem In batch mode, jump to the end of the file>>"%aliases%"
echo ;= goto:eof>>"%aliases%"
echo ;= Add aliases below here>>"%aliases%"
if not exist "%ALIASES%" (
echo ;= @echo off>"%ALIASES%"
echo ;= rem Call DOSKEY and use this file as the macrofile>>"%ALIASES%"
echo ;= %%SystemRoot%%\system32\doskey /listsize=1000 /macrofile=%%0%%>>"%ALIASES%"
echo ;= rem In batch mode, jump to the end of the file>>"%ALIASES%"
echo ;= goto:eof>>"%ALIASES%"
echo ;= Add aliases below here>>"%ALIASES%"
)
)

Expand Down Expand Up @@ -110,11 +110,11 @@ exit /b

:p_help
echo.Usage:
echo.
echo.
echo. alias [options] [alias=full command]
echo.
echo.
echo.Options:
echo.
echo.
echo. /d [alias] Delete an [alias].
echo. /f [macrofile] Path to the [macrofile] you want to store the new alias in.
echo. Default: %cmder_root%\config\user-aliases.cmd
Expand Down

0 comments on commit 3bf07c0

Please sign in to comment.