Groups | Search | Server Info | Login | Register


Groups > alt.msdos.batch.nt > #19677

Comma in an argument value

From Anton Shepelev <anton.txt@g{oogle}mail.com>
Newsgroups alt.msdos.batch.nt
Subject Comma in an argument value
Date 2024-11-27 19:21 +0300
Organization A noiseless patient Spider
Message-ID <20241127192124.193fe3828c9b4b25d1ec55fe@g{oogle}mail.com> (permalink)

Show all headers | View raw


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?

-- 
()  ascii ribbon campaign -- against html e-mail
/\  www.asciiribbon.org   -- against proprietary attachments

Back to alt.msdos.batch.nt | Previous | NextNext in thread | Find similar


Thread

Comma in an argument value Anton Shepelev <anton.txt@g{oogle}mail.com> - 2024-11-27 19:21 +0300
  Re: Comma in an argument value Herbert Kleebauer <klee@unibwm.de> - 2024-11-27 19:18 +0100
    Re: Comma in an argument value Anton Shepelev <anton.txt@g{oogle}mail.com> - 2024-12-05 11:51 +0300
      Re: Comma in an argument value "R.Wieser" <address@is.invalid> - 2024-12-05 11:34 +0100
        Re: Comma in an argument value "R.Wieser" <address@is.invalid> - 2024-12-05 16:32 +0100
      Re: Comma in an argument value Herbert Kleebauer <klee@unibwm.de> - 2024-12-05 16:44 +0100
        Re: Comma in an argument value "R.Wieser" <address@is.invalid> - 2024-12-05 18:30 +0100
  Re: Comma in an argument value JJ <jj4public@outlook.com> - 2024-11-28 02:04 +0700

csiph-web