On Thu, 14 Jan 2021 17:46:32 -0800,
hongy...@gmail.com wrote:
> On Friday, January 15, 2021 at 1:37:05 AM UTC+8, Lew Pitcher wrote:
>> On Wed, 13 Jan 2021 16:53:26 -0800,
hongy...@gmail.com wrote:
>>
>> > The following tcl and shell mixing script is one of the examples
>> > taken
>> from the directory of the expect5.45.4 distribution:
>> >
>> > #------> begin of the excerption <-------
>> > $ cat expect5.45.4/example/read1char #!/bin/sh # -*- tcl -*-
>> > # The next line is executed by /bin/sh, but not tcl \
>> > exec tclsh "$0" ${1+"$@"}
>> >
>> > package require Expect
>> >
>> > # read a single character # Author: Don Libes, NIST
>> >
>> > stty raw expect ?
>> > send_user $expect_out(buffer)
>> > #------> end of the excerption <-------
>> >
>> > I really can't figure out what's the function of the following two
>> lines used as shown above:
>> >
>> > stty raw expect ?
>> >
>> > Any hints will be highly appreciated.
>> The hashbang line starts /bin/bash, which interprets the script One of
>> the first instructions in the script exec tclsh "$0" ${1+"$@"}
>
> Why not use a more rigorous checklist that works in both cases of $1,
> i.e., null or unset, as shown below:
Don't ask me, I didn't write that script. It's certainly not how I would
implement an expect script.
I'd rather not. I rarely take the advice of a multitude of amateurs and
self-taught programmers answering questions from other amateurs.
[snip]
>> stty raw not being an expect(1) command, is taken as the commandline
>> command stty raw which sets the terminal into "raw" mode, removing the
>> special interpretation usually given to various control-characters that
>> you might receive or enter into a terminal (see stty(1))
>
> I can't find the above description from the document:
>
> $ man stty | egrep -A3 -i '^[ ]+raw'
> raw same as -ignbrk -brkint -ignpar -parmrk -inpck -istrip
> -inlcr
> -igncr -icrnl -ixon -ixoff -icanon -opost -isig -iuclc
> -ixany -imaxbel -xcase min 1 time 0
Then you either didn't read the stty(1) manpage well enough, or you don't
understand what you are reading.
Quote:
raw same as -ignbrk -brkint -ignpar -parmrk -inpck -istrip
-inlcr -igncr -icrnl -ixon -ixoff -icanon -opost
-isig -iuclc -ixany -imaxbel -xcase min 1 time 0
endquote
For stty, "- before SETTING indicates negation",
-ignbrk /DONT/ ignore break characters (break is a logic-low
signal sent over a serial line /instead/ of the usual
mark/space of a valid character, usually indicating some
sort of data interruption
-brkint breaks /DO NOT/ cause an interrupt signal
-ignpar /DONT/ ignore characters with parity errors
-parmrk /DONT/ mark parity errors
-inpck /DONT/ enable parity checking
-istrip /DONT/ clear high bit of input characters
-inlcr /DONT/ translate newline to carriage return
-igncr /DONT/ ignore carriage return
-icrnl /DONT/ translate carriage return to newline
-ixon /DONT/ enable XON/XOFF flow control
-ixoff /DONT/ enable sending of start/stop characters
-icanon /DONT/ enable special characters; erase/kill/werase/rprnt
-opost /DONT/ postprocess output
-isig /DONT/ enable interrupt, quit, and suspend special
characters
-iuclc /DONT/ translate uppercase characters to lowercase
-ixany /DONT/ let any character restart output
-imaxbel /DONT/ beep, and do flush a full input buffer
-xcase /DONT/ escape with '\' for uppercase characters
Note that the default terminal settings are represented by the stty
"sane" value (see stty(1) for what that means), which, for the most part,
is exactly the opposite of the "raw" settings.
[snip]