Menu

#88 File / Pipe not closed after SET /P

open
nobody
FreeCOM (7)
5
2018-09-04
2011-12-10
No

If I use SET /P to set a parameter from a file / pipe, like
SET /P hello= < world.txt
it will work fine, but if I use it repeatedly, it will continue reading the following lines, and eventually start over, as opposed to keep outputting the first line
(What my Windows XP does).

Discussion

  • tom ehlert

    tom ehlert - 2016-08-26

    also: with world.txt containing

    world1
    world2
    01.12.2016

    execute

    set /p hello1=<world.txt
    set /p hello2=<world.txt
    date

    echo %hello1%
    echo %hello2%
    echo %date%

    should be fixed by maintainer; results from freely mixing

    open()/dup() for file redirection, and fgets() for actual input
    processing

    fix: SHELL\COMMAND.C

    int oldinfd = -1; / original file descriptor #0 (stdin) /
    int oldoutfd = -1; / original file descriptor #1 (stdout) /
    +long oldstdinpos;

    ...

    if (in || (num > 1)) / Need to preserve stdin /
    {
    oldinfd = dup(0);
    + oldstdinpos = ftell(stdin);
    }
    ...

    if (oldinfd != -1) / Restore original STDIN /
    {
    close(0);
    dup2(oldinfd, 0);
    + fseek(stdin, oldstdinpos, SEEK_SET );

    close(oldinfd);
    oldinfd = -1;
    

    }

    now I'm wondering how long it takes for

    a) a new version of command.com on the website,

    b) updateable by the famous FreeDOS 1.0 package management process,

    c) updateable by the famous FreeDOS 1.1 package management process, which is different

    d) updateable by the famous FreeDOS 1.2 package management process,
    which is probably different, again

     
  • Bart Oldeman

    Bart Oldeman - 2018-09-04

    I can't reproduce this anymore with the newest pre's (which no longer use stream i/o except for debug statements)

     

Log in to post a comment.