mridgers / clink

Bash's powerful command line editing in cmd.exe
mridgers.github.io/clink
GNU General Public License v3.0
3.15k stars 286 forks source link

Cmd gets unresponsive after "set /p" command #552

Closed chrisant996 closed 3 years ago

chrisant996 commented 3 years ago

@mridgers ,

The OPs command string reproducing the problem is, as displayed, incorrect (likely, a formatting issue). But the issue is present.

The simplest problematic command line is:

set /p = <NUL

This command string (a valid, working construct for CMD), causes CMD with clink to hang (with no response to CTRL-C. Constructs such as this are used to initialize files...

set /p = <NUL >FILE creates a 0 byte file, "FILE" set /p =foo <NUL >FILE creates a 3-byte file, "FILE", containing only 'foo', without a newline

Of note, the alternative construct echo | set /p = >FILE does work correctly, without hanging, under CMD with clink.

Additionally, set /p VAR="" shows an incorrect prompt. It prints a shell prompt (from %PROMPT%), which is usually the current path followed by '>', e.g. "C:\Users>". It should print nothing. But, notably, set /p VAR="" does not hang; it correctly waits for a user input line and then sets VAR correctly.

Thanks for looking into it.

Originally posted by @rivy in https://github.com/mridgers/clink/issues/398#issuecomment-313881322

chrisant996 commented 3 years ago

Oops. I was trying to import issue 398 into another repo, but I accidentally created the new issue here.