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
In reply to Re: Invoking Perl via batchfile: ampersand in PATH ( this.bat )
by Anonymous Monk
in thread [OT] Invoking Perl via batchfile: ampersand in PATH [Solved]
by Athanasius
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |