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 68,874 of 68,980    |
|    JJ to Anton Shepelev    |
|    Re: Comma in an argument value    |
|    28 Nov 24 02:04:32    |
   
   From: jj4public@outlook.com   
      
   On Wed, 27 Nov 2024 19:21:24 +0300, Anton Shepelev wrote:   
   > Hello, all.   
   >   
   > What does the following script:   
   >   
   > @ECHO OFF   
   > FOR /F "tokens=2,* delims= " %%A in ("%*") DO SET ARGS=%%B   
   > ECHO M:1:%1   
   > ECHO M:2:%2   
   > ECHO M:*:%ARGS%   
   >   
   > stored as test.bat invoked as   
   >   
   >> test.bat a "b,c" d e   
   >   
   > print:   
   >   
   > 1:a   
   > 2:"b,c"   
   > *:c" d e   
   >   
   > ?   
   >   
   > I expected it to print:   
   >   
   > 1:a   
   > 2:"b,c"   
   > *:d e   
   >   
   > because the FOR /F loop should split the parameter by the   
   > space characer, and end up with all the token after the second   
   > one in the ARGS variable. Why is the comma treated as a command   
   > separator at some point?   
      
   It's because of delimiters, which AFAIK, is undocumented.   
      
   These delimiters are & can be used to separate between a command and its   
   arguments:   
    ( + , . / : ; = [ \ ]   
      
   These delimiters are & can be used to separate between arguments (note:   
   double-quote take precedence):   
    , ; =   
      
   --- SoupGate-DOS v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca