Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch.nt    |    Fun with Windows NT batch files    |    68,980 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 67,969 of 68,980    |
|    Kerr-Mudd, John to R.Wieser    |
|    Re: echo a variable containing an & some    |
|    20 Nov 22 13:08:13    |
      From: admin@127.0.0.1              On Sun, 20 Nov 2022 12:48:12 +0100       "R.Wieser" wrote:              > Hello all,       >       > I've written a test batch showing a directory tree. In it I noticed that       > echo-ing an argument containing a pathname containing an "&" causes a       > problem when done directly :       >       > echo %~xn1       >              '&' is seen as a command concatenation symbol; e.g.       echo Missed it!&cls                     > but doesn't when done indirectly :       >       > for %%a in (%1) do echo %%~xna       >       > Does anyone have an explanation for it ?              DelayedExpansion set?              >       >       > And a question : How do I tell the batchfile parser *not* to parse the %~xn1       > results but instead just display it as-is ?              Ah so you kind of knew why!       >       > I know that I can wrap it in doublequotes :       >       > echo "%~xn1"       >       > but those doublequotes get displayed too. :-(       >              Don't make directory names with '&' in them?       (Sorry, not very helpfull)                     --       Bah, and indeed Humbug.              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca