On Thu, 6 Jun 2024 17:08:50 GMT, Naoto Sato <na...@openjdk.org> wrote:

>> test/jdk/java/io/Console/restoreEcho.exp line 57:
>> 
>>> 55: test "$rpprompt" "$rpinput" "-echo" "$rpexpected"
>>> 56: # See if the initialEcho is restored with `stty -a`
>>> 57: expect " $initialEcho "
>> 
>> If you leave out those whitespace characters inside the quotes and 
>> `$initialEcho` expands to `-echo`, it will be treated as an option to 
>> `expect`, right? If so, consider this instead:
>> 
>>     expect -- $initialEcho
>> 
>> But more importantly: could a test match `echo` in `-echo` and therefore 
>> falsely pass?
>
> The spaces before/after `$initialEcho` are exactly to distinguish "echo" from 
> "-echo", otherwise the test falsely succeeds as you pointed out. Although the 
> test works as expected as it is, adding `--` would be safer.

It's clever. However, we now depend on `(-)echo` being in the middle of the 
line, no? If `stty -a` format (IEEE Std 1003.2) allows `(-)echo` to appear in 
an arbitrary position of a line, our check won't work.

If `(-)echo` appears in a leading position, it might be preceded by a TAB 
(similarly to `-echoprt` below). If `(-)echo` appears in a trailing position, 
it is followed by newline (similarly to `echoctl` below).


lflags: icanon isig iexten echo echoe -echok echoke -echonl echoctl$
^I-echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo$
^I-extproc$


But I guess, it's good enough and certainly much better than the initially 
proposed unit test.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/19315#discussion_r1630230512

Reply via email to