in reply to [OT] Invoking Perl via batchfile: ampersand in PATH [Solved]
So, is there an equivalent of quotemeta for Windows batch files? Or another workaround?
make a hard link with a shorter name without spaces and amperstands
or do the best and most closest approximation of quotemeta, see this.bat, this2.bat ... & is particularly stupid but doable
this3.bat
@setlocal @set "thisfile=%~f0" @echo "%thisfile%" @set "thisfile=%thisfile:^=\^%" @set "thisfile=%thisfile:>=^>%" @set "thisfile=%thisfile:<=^<%" @set "thisfile=%thisfile:&=^&%" @set "thisfile=%thisfile:|=^|%" @set "thisfile=%thisfile:)=^)%" @set "thisfile=%thisfile:(=^(%" @set "thisfile=%thisfile:[=^[%" @set "thisfile=%thisfile:]=^]%" @set "thisfile=%thisfile:"=\"%" @echo escaped-thisfile "%thisfile%" @echo; @endlocal
$ "rock&roll\this3.bat" "D:\rock&roll\this3.bat" escaped-thisfile "D:\rock^&roll\this3.bat" $ D:\rock^&roll\this3.bat "D:\rock&roll\this3.bat" escaped-thisfile "D:\rock^&roll\this3.bat"
Its triple interpolation, or eval interpolation , or ... whatever, its batguano :P
See also the following, maybe improve to make hard links for &nonsense vienv - Edit local environment variables on Win32, CleanPath , SetEnviron.bat
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Invoking Perl via batchfile: ampersand in PATH ( this.bat )
by Athanasius (Archbishop) on Nov 02, 2015 at 10:09 UTC | |
by Anonymous Monk on Nov 02, 2015 at 10:21 UTC |