1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Environment variables, set and input

Discussion in 'Support' started by Eric Pement, Oct 23, 2008.

  1. Eric Pement

    Jun 28, 2008
    Likes Received:
    I have a question about set. The docs for set says that "If you do not specify a filename and input is redirected, SET /R will read from stdin." But how does one redirect input without specifying a filename? The only way I know to do that is with a pipe. But this fails, as this demo shows.

    [ C:\eric_p\bat ]

    TCC 9.02.152 Windows XP [Version 5.1.2600]

    [ C:\eric_p\bat ]
    [0]>type xyz.btm
    @echo off
    echo Demonstration script
    echo 0 input params: %*
    echo 1 piped to set
    echo VAR1=PIPED %* | set /r
    echo Value of var1 is (%var1)
    echo 2 redirected to set
    echo VAR2=REDIRECT %* > file && set /r < file
    echo Value of var2 is (%var2)
    del /q file

    [ C:\eric_p\bat ]
    [0]>xyz aa :bb: c=d -e-f-g
    Demonstration script
    0 input params: aa :bb: c=d -e-f-g

    1 piped to set
    Value of var1 is ()

    2 redirected to set
    Value of var2 is (REDIRECT aa :bb: c=d -e-f-g)

    Any comments? It does appear as if set ought to accepted piped input, but that it does not. (That is, unless I have an old version of TCC that has a bug here.)

  2. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    May 20, 2008
    Likes Received:
    If I'm not mistaken, piping to SET /R will set the variables ... in the right-hand shell, which exits when it reaches the end of the piped data. It "works", but does nothing useful.

    The help file is referring to the SET /R < FILENAME syntax. I don't see that it offers anything that SET /R FILENAME doesn't, though.
  3. vefatica

    May 20, 2008
    Likes Received:
    On Thu, 23 Oct 2008 18:55:34 -0500, "JP Software Forums" <neil@jpsoft.com>,Eric
    Pement <> wrote:

    I think the help means a simple:

    SET /R

    That will read from the console.

Share This Page