Package: expect Version: 5.45.4-3+b1 Severity: minor Tags: patch * What led up to the situation?
Checking for defects with a new version test-[g|n]roff -mandoc -t -K utf8 -rF0 -rHY=0 -ww -z < "man page" [Use "groff -e ' $' <file>" to find trailing spaces.] ["test-groff" is a script in the repository for "groff"; is not shipped] (local copy and "troff" slightly changed by me). [The fate of "test-nroff" was decided in groff bug #55941.] * What was the outcome of this action? an.tmac:<stdin>:1: style: .TH missing fourth argument; consider package/project name and version (e.g., "groff 1.23.0") an.tmac:<stdin>:111: style: 4 leading space(s) on input line troff:<stdin>:126: warning: trailing space in the line troff:<stdin>:133: warning: trailing space in the line an.tmac:<stdin>:212: style: 4 leading space(s) on input line troff:<stdin>:220: warning: trailing space in the line an.tmac:<stdin>:317: style: .BR expects at least 2 arguments, got 1 troff:<stdin>:323: warning: trailing space in the line troff:<stdin>:359: warning: trailing space in the line troff:<stdin>:373: warning: trailing space in the line troff:<stdin>:440: warning: trailing space in the line troff:<stdin>:504: warning: trailing space in the line troff:<stdin>:620: warning: trailing space in the line troff:<stdin>:804: warning: trailing space in the line troff:<stdin>:927: warning: trailing space in the line an.tmac:<stdin>:954: style: .BR expects at least 2 arguments, got 1 troff:<stdin>:1016: warning: trailing space in the line troff:<stdin>:1173: warning: trailing space in the line troff:<stdin>:1203: warning: trailing space in the line troff:<stdin>:1341: warning: trailing space in the line troff:<stdin>:1343: warning: trailing space in the line troff:<stdin>:1354: warning: trailing space in the line troff:<stdin>:1412: warning: trailing space in the line an.tmac:<stdin>:1550: style: .IR expects at least 2 arguments, got 1 troff:<stdin>:1588: warning: trailing space in the line troff:<stdin>:1613: warning: trailing space in the line an.tmac:<stdin>:1626: style: .IR expects at least 2 arguments, got 1 troff:<stdin>:1634: warning: trailing space in the line troff:<stdin>:1635: warning: trailing space in the line an.tmac:<stdin>:1665: style: .BR expects at least 2 arguments, got 1 an.tmac:<stdin>:1668: style: .BR expects at least 2 arguments, got 1 troff:<stdin>:2056: warning: trailing space in the line troff:<stdin>:2101: warning: trailing space in the line troff:<stdin>:2148: warning: trailing space in the line troff:<stdin>:2164: warning: trailing space in the line troff:<stdin>:2271: warning: trailing space in the line troff:<stdin>:2292: warning: trailing space in the line * What outcome did you expect instead? No output (no warnings). -.- General remarks and further material, if a diff-file exist, are in the attachments. -- System Information: Debian Release: trixie/sid APT prefers testing APT policy: (500, 'testing') Architecture: amd64 (x86_64) Kernel: Linux 6.11.10-amd64 (SMP w/2 CPU threads; PREEMPT) Locale: LANG=is_IS.iso88591, LC_CTYPE=is_IS.iso88591 (charmap=ISO-8859-1), LANGUAGE not set Shell: /bin/sh linked to /usr/bin/dash Init: sysvinit (via /sbin/init) Versions of packages expect depends on: ii libc6 2.40-4 ii libtcl8.6 8.6.15+dfsg-2 ii tcl-expect 5.45.4-3+b1 ii tcl8.6 8.6.15+dfsg-2 expect recommends no packages. Versions of packages expect suggests: ii tk8.6 8.6.15-1 -- no debconf information
Input file is expect.1 Any program (person), that produces man pages, should check the output for defects by using (both groff and nroff) [gn]roff -mandoc -t -ww -b -z -K utf8 <man page> The same goes for man pages that are used as an input. For a style guide use mandoc -T lint -.- So any 'generator' should check its products with the above mentioned 'groff', 'mandoc', and additionally with 'nroff ...'. This is just a simple quality control measure. The 'generator' may have to be corrected to get a better man page, the source file may, and any additional file may. Common defects: Input text line longer than 80 bytes. Not removing trailing spaces (in in- and output). The reason for these trailing spaces should be found and eliminated. Not beginning each input sentence on a new line. Lines should thus be shorter. See man-pages(7), item 'semantic newline'. -.- The difference between the formatted output of the original and patched file can be seen with: nroff -mandoc <file1> > <out1> nroff -mandoc <file2> > <out2> diff -u <out1> <out2> and for groff, using "printf '%s\n%s\n' '.kern 0' '.ss 12 0' | groff -mandoc -Z - " instead of 'nroff -mandoc' Add the option '-t', if the file contains a table. Read the output of 'diff -u' with 'less -R' or similar. -.-. If 'man' (man-db) is used to check the manual for warnings, the following must be set: The option "-warnings=w" The environmental variable: export MAN_KEEP_STDERR=yes (or any non-empty value) or (produce only warnings): export MANROFFOPT="-ww -b -z" export MAN_KEEP_STDERR=yes (or any non-empty value) -.-. Output from "mandoc -T lint expect.1": (shortened list) 5 input text line longer than 80 bytes 1 line scope broken 30 whitespace at end of input line -.-. Output from "test-groff -mandoc -t -ww -z expect.1": (shortened list) 28 trailing space in the line -.-. Remove space characters (whitespace) at the end of lines. Use "git apply ... --whitespace=fix" to fix extra space issues, or use global configuration "core.whitespace". Number of lines affected is 31 -.-. Change '-' (\-) to '\(en' (en-dash) for a numeric range. GNU gnulib has recently (2023-06-18) updated its "build_aux/update-copyright" to recognize "\(en" in man pages. expect.1:2066: %d day of the month (01-31) expect.1:2067: %H hour (00-23) expect.1:2068: %I hour (01-12) expect.1:2069: %j day (001-366) expect.1:2070: %m month (01-12) expect.1:2071: %M minute (00-59) expect.1:2073: %S second (00-61) expect.1:2074: %u day (1-7, Monday is first day of week) expect.1:2075: %U week (00-53, first Sunday is first day of week one) expect.1:2076: %V week (01-53, ISO 8601 style) expect.1:2077: %w day (0-6) expect.1:2078: %W week (00-53, first Monday is first day of week one) expect.1:2081: %y year (00-99) expect.1:2561:\fRby Don Libes, pp. 602, ISBN 1-56592-090-2, O'Reilly and Associates, 1995. expect.1:2566:Anaheim, California, June 11-15, 1990. expect.1:2573:Conference, Colorado Springs, Colorado, October 17-19, 1990. expect.1:2578:Washington, D.C., January 22-26, 1990. expect.1:2587:Libes, Proceedings of the Summer 1992 USENIX Conference, pp. 135-144, expect.1:2588:San Antonio, TX, June 12-15, 1992. expect.1:2597:Proceedings of the 1993 Tcl/Tk Workshop, Berkeley, CA, June 10-11, 1993. -.-. Use the correct macro for the font change of a single argument or split the argument into two. 317:.BR \-onexec 954:.BR expect_background 1550:.IR "program args" 1626:.IR string 1665:.BR \-null 1668:.BR \-null -.-. Use "\e" to print the escape character instead of "\\" (which gets interpreted in copy mode). 251: send_user "$argv0 [lrange $argv 0 2]\\n" 389: send_user "password?\\ " 390: expect_user \-re "(.*)\\n" 396: send "$expect_out(1,string)\\r" 642: busy {puts busy\\n ; exp_continue} 666: busy {puts busy\\n ; exp_continue} 750:For example, if a process has produced output of "abcdefgh\\n", the result of: 763:and "efgh\\n" is left in the output buffer. 764:If a process produced the output "abbbcabkkkka\\n", the result of: 785:and "a\\n" is left in the output buffer. The pattern "*" (and \-re ".*") will 819: \-i $proc2 busy {puts busy\\n ; exp_continue} 879: expect_user \-re "(.*)\\n" 880: send_user "\\n" 881: send "$expect_out(1,string)\\r" 885: send_user "invalid password or account\\n" 888: send_user "connection to $host timed out\\n" 891: send_user \\ 915: "p" {send "\\r\\r\\r"; exp_continue} 1124: set CTRLZ \\032 1127: \\001 {send_user "you typed a control\-A\\n"; 1128: send "\\001" 1131: \\003 exit 1202: interact \-input $user_spawn_id timeout 3600 return \-output \\ 1319: interact \-nobuffer \-re "(.*)\\r" return 1631: send "hello world\\r" 1642:character is denoted "\\r". 1758: send password\\r 2021: expect_user \-re "(.*)\\n" 2330:does represent a single argument which has multiple embedded \\n's 2415: send "speed 9600\\r"; 2418: timeout {send "\\r"; exp_continue} 2449: set prompt "(%|#|\\\\$) $" ;# default prompt 2507:explicitly matches the two lines, from, say, printf("foo\\nbar"), 2508:you should use the pattern "foo\\r\\nbar". -.-. Move a full stop (period) and a comma outside of a quoted text, if it is at the end of the quote and does not end a quoted sentence. 687:note below on "system indigestion.") -.-. Change a HYPHEN-MINUS (code 0x2D) to a minus(-dash) (\-), if it is in front of a name for an option, is a symbol for standard input, is a single character used to indicate an option, or is in the NAME section (man-pages(7)). N.B. - (0x2D), processed as a UTF-8 file, is changed to a hyphen (0x2010, groff \[u2010] or \[hy]) in the output. 2335:-brace forces a single argument to be handle as multiple patterns/actions. 2360:define TERM. Thus, you must set it explicitly - to what type is 2372:them explicitly - to what type is usually irrelevant. It just has to -.-. Find a repeated word ! 626 --> may -.-. Add a comma (or \&) after "e.g." and "i.e.", or use English words (man-pages(7)). Abbreviation points should be protected against being interpreted as an end of sentence, if they are not, and that independent of the current place on the line. 1040:but it reads characters from /dev/tty (i.e. keystrokes from the user). 1054:but it reads characters from stdin (i.e. keystrokes from the user). 1910:cannot be spawned successfully because exec(2) fails (e.g. when -.-. Wrong distance between sentences in the input file. Separate the sentences and subordinate clauses; each begins on a new line. See man-pages(7) ("Conventions for source file layout") and "info groff" ("Input Conventions"). The best procedure is to always start a new sentence on a new line, at least, if you are typing on a computer. Remember coding: Only one command ("sentence") on each (logical) line. E-mail: Easier to quote exactly the relevant lines. Generally: Easier to edit the sentence. Patches: Less unaffected text. Search for two adjacent words is easier, when they belong to the same line, and the same phrase. The amount of space between sentences in the output can then be controlled with the ".ss" request. -.- Mark a abbreviation point as such by suffixing them with "\\&". 108:may also be invoked implicitly on systems which support the #! notation 164:the #! notation (see above), 207:This can usefully be placed in the #! line to prevent any flag-like 215:when adding arguments to the #! line. 463:executing rather than returning as it normally would. By 466:resets the timeout timer. The 468:flag prevents timer from being restarted. (See 684:lines respectively. However, because expect is not line oriented, 1040:but it reads characters from /dev/tty (i.e. keystrokes from the user). 1054:but it reads characters from stdin (i.e. keystrokes from the user). 1095:string is not sent to the current process.) The 1155:Any pattern beginning with a "\-" should be protected this way. (All strings 1730:output and for human-style output are mutually exclusive. Only the one 1731:specified last will be used. Furthermore, no 1910:cannot be spawned successfully because exec(2) fails (e.g. when 2561:\fRby Don Libes, pp. 602, ISBN 1-56592-090-2, O'Reilly and Associates, 1995. 2582:Computing Systems, Vol. 4, No. 2, University of California Press Journals, 2587:Libes, Proceedings of the Summer 1992 USENIX Conference, pp. 135-144, 2593:Vol. 23, No. 5, May, 1993. 2612:was paid for in part by the U.S. government and is therefore in the public -.-. Split lines longer than 80 characters into two or more lines. Appropriate break points are the end of a sentence and a subordinate clause; after punctuation marks. Line 74, length 91 Run fsck, and in response to its questions, answer "yes", "no" or give control back to you, Line 1023, length 143 By default, it reports on the current spawn id. An optional spawn id specification may be given for information on that spawn id. For example Line 1262, length 89 itself, first call interpreter (perhaps by using an escape character), and then press ^Z. Line 1320, length 82 puts $log "[clock format [clock seconds]]: dialed $interact_out(1,string)" Line 2446, length 104 can be used. If EXPECT_PROMPT doesn't exist, the code still has a good chance of functioning correctly. -.-. Use \(en (en-dash) for a dash at the beginning of a line, or between space characters, not a minus (\-) or a hyphen (-), except in the NAME section. expect.1:2360:define TERM. Thus, you must set it explicitly - to what type is expect.1:2372:them explicitly - to what type is usually irrelevant. It just has to -.-. Do not use more than two space characters between sentences or (better) only a new line character. 1095:string is not sent to the current process.) The 1155:Any pattern beginning with a "\-" should be protected this way. (All strings -.-. Add a zero (0) in front of a decimal fraction that begins with a period (.) 1687:must be separated. For example, "set send_slow {10 .001}" would force 1701:transitions. The third parameter is a measure of variability where .1 1714: set send_human {.1 .3 1 .05 2} 1721: set send_human {.4 .4 .2 .5 100} -.-. Split a punctuation from a single argument, if a two-font macro is meant 843:.I any_spawn_id. -.-. Name of a manual is set in bold, the section in roman. See man-pages(7). 1910:cannot be spawned successfully because exec(2) fails (e.g. when 2187:See signal(3) for more info. -.-. Put a parenthetical sentence, phrase on a separate line, if not part of a code. See man-pages(7), item "semantic newline". Not considered in a patch, too many lines. expect.1:45:can also be used directly in C or C++ (that is, without Tcl). expect.1:70:restart it (again and again) until it does, expect.1:78:Connect to another network or BBS (e.g., MCI Mail, CompuServe) and [...] expect.1:2530:It is often useful to store passwords (or other private information) expect.1:2545:script (that contains the secret data) as usual. expect.1:2546:Make its permissions be 750 (\-rwxr\-x\-\-\-) and owned by a trusted group, expect.1:2549:permissions 2751 (\-rwxr\-s\-\-x) owned by the same group as before. -.-. "[" and "]", showing optional arguments to options, should be typeset in roman. Too many lines to include in a patch. 15:.BR \- [ f | b ] 296:.BI close " [\-slave] [\-onexec 0|1] [\-i spawn_id]" 342:.BI debug " [[\-now] 0|1]" 416:.BI exit " [\-opts] [status]" 472:.BI exp_internal " [\-f file] value" 494:.BI exp_open " [args] [\-i spawn_id]" 509:.BI exp_pid " [\-i spawn_id]" 535:.BI exp_version " [[\-exit] version]" 574:.BI expect " [[\-opts] pat1 body1] ... [\-opts] patn [bodyn]" 931:.BI expect_after " [expect_args]" 944:.BI expect_background " [expect_args]" 987:.BI expect_before " [expect_args]" 1037:.BI expect_tty " [expect_args]" 1051:.BI expect_user " [expect_args]" 1088:.BI interact " [string1 body1] ... [stringn [bodyn]]" 1483:.BI log_file " [args] [[\-a] file]" 1533:.BI match_max " [\-d] [\-i spawn_id] [size]" 1548:.BI overlay " [\-# spawn_id] [\-# spawn_id] [...] program [args]" 1577:.BI parity " [\-d] [\-i spawn_id] [value]" 1595:.BI remove_nulls " [\-d] [\-i spawn_id] [value]" 1624:.BI send " [\-flags] string" 1771:.BI send_error " [\-flags] string" 1777:.BI send_log " [\-\-] string" 1784:.BI send_tty " [\-flags] string" 1790:.BI send_user " [\-flags] string" 1801:.BI spawn " [args] program [args]" 2049:.BI timestamp " [args]" 2100:.BI trap " [[command] signals]" 2189:.BI wait " [args]" -.-. Output from "test-groff -mandoc -t -K utf8 -rF0 -rHY=0 -rCHECKSTYLE=10 -ww -z ": an.tmac:<stdin>:1: style: .TH missing fourth argument; consider package/project name and version (e.g., "groff 1.23.0") an.tmac:<stdin>:111: style: 4 leading space(s) on input line troff:<stdin>:126: warning: trailing space in the line troff:<stdin>:133: warning: trailing space in the line an.tmac:<stdin>:212: style: 4 leading space(s) on input line troff:<stdin>:220: warning: trailing space in the line an.tmac:<stdin>:317: style: .BR expects at least 2 arguments, got 1 troff:<stdin>:323: warning: trailing space in the line troff:<stdin>:359: warning: trailing space in the line troff:<stdin>:373: warning: trailing space in the line troff:<stdin>:440: warning: trailing space in the line troff:<stdin>:504: warning: trailing space in the line troff:<stdin>:620: warning: trailing space in the line troff:<stdin>:804: warning: trailing space in the line troff:<stdin>:927: warning: trailing space in the line an.tmac:<stdin>:954: style: .BR expects at least 2 arguments, got 1 troff:<stdin>:1016: warning: trailing space in the line troff:<stdin>:1173: warning: trailing space in the line troff:<stdin>:1203: warning: trailing space in the line troff:<stdin>:1341: warning: trailing space in the line troff:<stdin>:1343: warning: trailing space in the line troff:<stdin>:1354: warning: trailing space in the line troff:<stdin>:1412: warning: trailing space in the line an.tmac:<stdin>:1550: style: .IR expects at least 2 arguments, got 1 troff:<stdin>:1588: warning: trailing space in the line troff:<stdin>:1613: warning: trailing space in the line an.tmac:<stdin>:1626: style: .IR expects at least 2 arguments, got 1 troff:<stdin>:1634: warning: trailing space in the line troff:<stdin>:1635: warning: trailing space in the line an.tmac:<stdin>:1665: style: .BR expects at least 2 arguments, got 1 an.tmac:<stdin>:1668: style: .BR expects at least 2 arguments, got 1 troff:<stdin>:2056: warning: trailing space in the line troff:<stdin>:2101: warning: trailing space in the line troff:<stdin>:2148: warning: trailing space in the line troff:<stdin>:2164: warning: trailing space in the line troff:<stdin>:2271: warning: trailing space in the line troff:<stdin>:2292: warning: trailing space in the line -.-. Additionally (general): Abbreviations get a '\&' added after their final full stop (.) to mark them as such and not as an end of a sentence.
--- expect.1 2024-12-14 13:56:39.527874044 +0000 +++ expect.1.new 2024-12-17 01:23:12.246228976 +0000 @@ -71,7 +71,8 @@ restart it (again and again) until it do then hand over control to you. .TP \(bu -Run fsck, and in response to its questions, answer "yes", "no" or give control back to you, +Run fsck, and in response to its questions, +answer "yes", "no" or give control back to you, based on predetermined criteria. .TP \(bu @@ -105,7 +106,7 @@ reads .I cmdfile for a list of commands to execute. .B Expect -may also be invoked implicitly on systems which support the #! notation +may also be invoked implicitly on systems which support the #!\& notation by marking the script executable, and making the first line in your script: #!/usr/bin/expect \-f @@ -123,14 +124,14 @@ Multiple commands may be executed with a single .B \-c by separating them with semicolons. -Commands are executed in the order they appear. +Commands are executed in the order they appear. (When using Expectk, this option is specified as .BR \-command .) .PP The .B \-d flag enables some diagnostic output, which -primarily reports internal activity of commands such as +primarily reports internal activity of commands such as .B expect and .BR interact . @@ -161,7 +162,7 @@ The .B \-f flag prefaces a file from which to read commands from. The flag itself is optional as it is only useful when using -the #! notation (see above), +the #!\& notation (see above), so that other arguments may be supplied on the command line. (When using Expectk, this option is specified as .BR \-file .) @@ -204,7 +205,7 @@ may be used to delimit the end of the op you want to pass an option-like argument to your script without it being interpreted by .BR Expect . -This can usefully be placed in the #! line to prevent any flag-like +This can usefully be placed in the #!\& line to prevent any flag-like interpretation by Expect. For example, the following will leave the original arguments (including the script name) in the variable .IR argv . @@ -212,12 +213,12 @@ original arguments (including the script #!/usr/bin/expect \-\- Note that the usual getopt(3) and execve(2) conventions must be observed -when adding arguments to the #! line. +when adding arguments to the #!\& line. .PP The file $exp_library/expect.rc is sourced automatically if present, unless the .B \-N -flag is used. +flag is used. (When using Expectk, this option is specified as .BR \-NORC .) Immediately after this, @@ -248,7 +249,7 @@ For example, the following prints out the name of the script and the first three arguments: .nf - send_user "$argv0 [lrange $argv 0 2]\\n" + send_user "$argv0 [lrange $argv 0 2]\en" .fi .SH COMMANDS @@ -314,13 +315,13 @@ you will need to explicitly call .BR close . The -.BR \-onexec +.B \-onexec flag determines whether the spawn id will be closed in any new spawned processes or if the process is overlayed. To leave a spawn id open, use the value 0. A non-zero integer value will force the spawn closed (the default) in any new processes. -The +The .B \-slave flag closes the slave associated with the spawn id. (See "spawn \-pty".) When the connection is closed, the slave is automatically closed as @@ -356,7 +357,7 @@ Tcl statement. The .B debug -command does not change any traps. Compare this to starting Expect with the +command does not change any traps. Compare this to starting Expect with the .B \-D flag (see above). @@ -370,7 +371,7 @@ Standard I/O is redirected to /dev/null. .IP The following fragment uses .B disconnect -to continue running the script in the background. +to continue running the script in the background. .nf if {[fork]!=0} exit @@ -386,14 +387,14 @@ the password so that you only have to ty command which demonstrates how to turn off password echoing.) .nf - send_user "password?\\ " - expect_user \-re "(.*)\\n" + send_user "password?\e " + expect_user \-re "(.*)\en" for {} 1 {} { if {[fork]!=0} {sleep 3600;continue} disconnect spawn priv_prog expect Password: - send "$expect_out(1,string)\\r" + send "$expect_out(1,string)\er" . . . exit } @@ -437,7 +438,7 @@ so that other Tcl extensions can clean u .B exit is called again (however this might occur), the handlers are not rerun. -Upon exiting, +Upon exiting, all connections to spawned processes are closed. Closure will be detected as an EOF by spawned processes. .B exit @@ -460,12 +461,14 @@ The command allows .B expect itself to continue -executing rather than returning as it normally would. By -default +executing rather than returning as it normally would. +By default .B exp_continue -resets the timeout timer. The +resets the timeout timer. +The .I \-continue_timer -flag prevents timer from being restarted. (See +flag prevents timer from being restarted. +(See .B expect for more information.) .TP @@ -501,7 +504,7 @@ should not be executed. The .B \-leaveopen -flag leaves the spawn id open for access through +flag leaves the spawn id open for access through Expect commands. A .B wait must be executed on the spawn id. @@ -547,7 +550,7 @@ is the major number. Scripts written fo .B Expect with a different major number will almost certainly not work. -.B exp_version +.B exp_version returns an error if the major numbers do not match. .IP Second is the minor number. Scripts written for a version with a @@ -617,13 +620,13 @@ In situations where there is no prompt, .B timeout (just like you would if you were interacting manually). .IP -Patterns are specified in three ways. By default, +Patterns are specified in three ways. By default, patterns are specified as with Tcl's .B string match command. (Such patterns are also similar to C-shell regular expressions usually referred to as "glob" patterns). The .B \-gl -flag may may +flag may be used to protect patterns that might otherwise match .B expect flags from doing so. @@ -639,7 +642,7 @@ is presumed to be a procedure defined el .ta \w' expect 'u +\w'invalid password 'u expect { - busy {puts busy\\n ; exp_continue} + busy {puts busy\en ; exp_continue} failed abort "invalid password" abort timeout abort @@ -663,7 +666,7 @@ The previous example can be rewritten us .ta \w' expect 'u +\w'connected 'u expect { - busy {puts busy\\n ; exp_continue} + busy {puts busy\en ; exp_continue} \-re "failed|invalid password" abort timeout abort connected @@ -681,10 +684,11 @@ can look unnatural. Thus, use of $ is e describe the characters at the end of a string. Note that in many editors, the ^ and $ match the beginning and end of -lines respectively. However, because expect is not line oriented, +lines respectively. +However, because expect is not line oriented, these characters match the beginning and end of the data (as opposed to lines) currently in the expect matching buffer. (Also, see the -note below on "system indigestion.") +note below on "system indigestion".) The .B \-ex @@ -747,7 +751,7 @@ and where X is a digit, corresponds to the substring position in the buffer. 0 refers to strings which matched the entire pattern and is generated for glob patterns as well as regexp patterns. -For example, if a process has produced output of "abcdefgh\\n", the result of: +For example, if a process has produced output of "abcdefgh\en", the result of: .nf expect "cd" @@ -760,8 +764,8 @@ is as if the following statements had ex set expect_out(buffer) abcd .fi -and "efgh\\n" is left in the output buffer. -If a process produced the output "abbbcabkkkka\\n", the result of: +and "efgh\en" is left in the output buffer. +If a process produced the output "abbbcabkkkka\en", the result of: .nf expect \-indices \-re "b(b*).*(k+)" @@ -782,7 +786,7 @@ is as if the following statements had ex set expect_out(buffer) abbbcabkkkk .fi -and "a\\n" is left in the output buffer. The pattern "*" (and \-re ".*") will +and "a\en" is left in the output buffer. The pattern "*" (and \-re ".*") will flush the output buffer without reading any more output from the process. .IP @@ -801,7 +805,7 @@ The flag causes the current expect command to use the following value as a timeout instead of using the value of the timeout variable. -By default, +By default, patterns are matched against output from the current process, however the .B \-i flag declares the output from the named spawn_id list be matched against @@ -816,7 +820,7 @@ password" from the spawn_id named by $pr .nf expect { - \-i $proc2 busy {puts busy\\n ; exp_continue} + \-i $proc2 busy {puts busy\en ; exp_continue} \-re "failed|invalid password" abort timeout abort connected @@ -840,7 +844,7 @@ is made available to any other patterns in the same .B expect command associated with -.I any_spawn_id. +.IR any_spawn_id . The .B \-i @@ -876,19 +880,19 @@ statement (to look for the prompt again) Password: { stty \-echo send_user "password (for $user) on $host: " - expect_user \-re "(.*)\\n" - send_user "\\n" - send "$expect_out(1,string)\\r" + expect_user \-re "(.*)\en" + send_user "\en" + send "$expect_out(1,string)\er" stty echo exp_continue } incorrect { - send_user "invalid password or account\\n" + send_user "invalid password or account\en" exit } timeout { - send_user "connection to $host timed out\\n" + send_user "connection to $host timed out\en" exit } eof { - send_user \\ + send_user \e "connection to host failed: $expect_out(buffer)" exit } \-re $prompt @@ -912,7 +916,7 @@ current action. stty raw \-echo expect_after { \-i $user_spawn_id - "p" {send "\\r\\r\\r"; exp_continue} + "p" {send "\er\er\er"; exp_continue} "+" {incr foo; exp_continue} "i" {interact; exp_continue} "quit" exit @@ -924,7 +928,7 @@ By default, .B exp_continue resets the timeout timer. The timer is not restarted, if .B exp_continue -is called with the +is called with the .B \-continue_timer flag. .TP @@ -951,7 +955,7 @@ The pattern and .B default are meaningless to -.BR expect_background +.B expect_background and are silently discarded. Otherwise, the .B expect_background @@ -1013,14 +1017,18 @@ Unless overridden by a .B \-i flag, .B expect_before -patterns match against the spawn id defined at the time that the +patterns match against the spawn id defined at the time that the .B expect_before command was executed (not when its pattern is matched). The \-info flag causes .B expect_before to return the current specifications of what patterns it will match. -By default, it reports on the current spawn id. An optional spawn id specification may be given for information on that spawn id. For example +By default, +it reports on the current spawn id. +An optional spawn id specification may be given for information on that spawn +id. +For example .nf expect_before \-info \-i $proc @@ -1037,7 +1045,8 @@ The output of the \-info flag can be reu .BI expect_tty " [expect_args]" is like .B expect -but it reads characters from /dev/tty (i.e. keystrokes from the user). +but it reads characters from /dev/tty +(i.e., keystrokes from the user). By default, reading is performed in cooked mode. Thus, lines must end with a return in order for .B expect @@ -1051,7 +1060,8 @@ command below). .BI expect_user " [expect_args]" is like .B expect -but it reads characters from stdin (i.e. keystrokes from the user). +but it reads characters from stdin +(i.e., keystrokes from the user). By default, reading is performed in cooked mode. Thus, lines must end with a return in order for .B expect @@ -1091,8 +1101,9 @@ keystrokes are sent to the current proce and the stdout and stderr of the current process are returned. .IP String-body pairs may be specified as arguments, in which case the -body is executed when the corresponding string is entered. (By default, the -string is not sent to the current process.) The +body is executed when the corresponding string is entered. +(By default, the string is not sent to the current process.) +The .B interpreter command is assumed, if the final body is missing. .IP @@ -1121,14 +1132,14 @@ interpreter runs interactively. .nf .ta \w' interact 'u +\w'$CTRLZ 'u +\w'{'u - set CTRLZ \\032 + set CTRLZ \e032 interact { \-reset $CTRLZ {exec kill \-STOP [pid]} - \\001 {send_user "you typed a control\-A\\n"; - send "\\001" + \e001 {send_user "you typed a control\-A\en"; + send "\e001" } $ {send_user "The date is [clock format [clock seconds]]."} - \\003 exit + \e003 exit foo {send_user "bar"} ~~ } @@ -1152,8 +1163,8 @@ command uses glob-style patterns by defa flag may be used to protect patterns that might otherwise match .B interact flags from doing so. -Any pattern beginning with a "\-" should be protected this way. (All strings -starting with "\-" are reserved for future options.) +Any pattern beginning with a "\-" should be protected this way. +(All strings starting with "\-" are reserved for future options.) The .B \-re @@ -1170,7 +1181,7 @@ flag is similarly supported. The pattern .B eof -introduces an action that is +introduces an action that is executed upon end-of-file. A separate .B eof pattern may also follow the @@ -1199,8 +1210,8 @@ not typed anything for an hour but who s messages: .nf - interact \-input $user_spawn_id timeout 3600 return \-output \\ - $spawn_id + interact \-input $user_spawn_id timeout 3600 return \-output \e + $spawn_id .fi @@ -1259,7 +1270,9 @@ If you really want to send a SIGSTOP to consider spawning csh first and then running your program. On the other hand, if you want to send a SIGSTOP to .B Expect -itself, first call interpreter (perhaps by using an escape character), and then press ^Z. +itself, first call interpreter +(perhaps by using an escape character), +and then press ^Z. .IP String-body pairs can be used as a shorthand for avoiding having to enter the interpreter and execute commands interactively. The previous @@ -1316,7 +1329,7 @@ logs the rest of the line. .nf proc lognumber {} { - interact \-nobuffer \-re "(.*)\\r" return + interact \-nobuffer \-re "(.*)\er" return puts $log "[clock format [clock seconds]]: dialed $interact_out(1,string)" } @@ -1338,9 +1351,9 @@ The flag causes any following key-body pairs to be applied to the output of the current process. This can be useful, for example, when dealing with hosts that -send unwanted characters during a telnet session. +send unwanted characters during a telnet session. .IP -By default, +By default, .B interact expects the user to be writing stdin and reading stdout of the .B Expect @@ -1351,7 +1364,7 @@ The flag (for "user") makes .B interact look for the user as the process named by its argument -(which must be a spawned id). +(which must be a spawned id). .IP This allows two unrelated processes to be joined together without using an explicit loop. To aid in debugging, Expect @@ -1409,7 +1422,7 @@ it overrides $spawn_id. Additional flags may be specified. The two implied input processes default to having their outputs specified as -$spawn_id and $user_spawn_id (in reverse). +$spawn_id and $user_spawn_id (in reverse). If a .B \-input flag appears @@ -1547,7 +1560,7 @@ the current process. .TP .BI overlay " [\-# spawn_id] [\-# spawn_id] [...] program [args]" executes -.IR "program args" +.I "program args" in place of the current .B Expect program, which terminates. @@ -1585,7 +1598,7 @@ argument, the current value is returned. .IP With the .B \-d -flag, the default parity value is set. (The initial default is 1, i.e., +flag, the default parity value is set. (The initial default is 1, i.e., parity is not stripped.) With the .B \-i @@ -1596,7 +1609,7 @@ the current process. defines whether nulls are retained or removed from the output of spawned processes before pattern matching or storing in the variable -.I expect_out +.I expect_out or .IR interact_out . If @@ -1610,7 +1623,7 @@ argument, the current value is returned. .IP With the .B \-d -flag, the default value is set. (The initial default is 1, i.e., +flag, the default value is set. (The initial default is 1, i.e., nulls are removed.) With the .B \-i @@ -1623,23 +1636,23 @@ will record null bytes to the log and st .TP .BI send " [\-flags] string" Sends -.IR string +.I string to the current process. For example, the command .nf - send "hello world\\r" + send "hello world\er" .fi -sends the characters, h e l l o <blank> w o r l d <return> to the -current process. +sends the characters, h e l l o <blank> w o r l d <return> to the +current process. (Tcl includes a printf-like command (called .BR format ) which can build arbitrarily complex strings.) .IP Characters are sent immediately although programs with line-buffered input will not read the characters until a return character is sent. A return -character is denoted "\\r". +character is denoted "\er". The .B \-\- @@ -1662,10 +1675,10 @@ The flag disables this translation. The -.BR \-null +.B \-null flag sends null characters (0 bytes). By default, one null is sent. An integer may follow the -.BR \-null +.B \-null to indicate how many nulls to send. The @@ -1684,7 +1697,7 @@ controlled by the value of the variable element list. The first element is an integer that describes the number of bytes to send atomically. The second element is a real number that describes the number of seconds by which the atomic sends -must be separated. For example, "set send_slow {10 .001}" would force +must be separated. For example, "set send_slow {10 0.001}" would force "send \-s" to send strings with 1 millisecond in between each 10 characters sent. @@ -1698,7 +1711,7 @@ the variable "send_human" which takes a two elements are average interarrival time of characters in seconds. The first is used by default. The second is used at word endings, to simulate the subtle pauses that occasionally occur at such -transitions. The third parameter is a measure of variability where .1 +transitions. The third parameter is a measure of variability where 0.1 is quite variable, 1 is reasonably variable, and 10 is quite invariable. The extremes are 0 to infinity. The last two parameters are, respectively, a minimum and maximum interarrival time. @@ -1711,14 +1724,14 @@ example, the following command emulates consistent typist: .nf - set send_human {.1 .3 1 .05 2} + set send_human {0.1 0.3 1 0.05 2} send \-h "I'm hungry. Let's do lunch." .fi while the following might be more suitable after a hangover: .nf - set send_human {.4 .4 .2 .5 100} + set send_human {0.4 0.4 0.2 0.5 100} send \-h "Goodd party lash night!" .fi @@ -1727,8 +1740,9 @@ correction situations yourself by embedd in a send argument. The flags for sending null characters, for sending breaks, for forcing slow -output and for human-style output are mutually exclusive. Only the one -specified last will be used. Furthermore, no +output and for human-style output are mutually exclusive. +Only the one specified last will be used. +Furthermore, no .I string argument can be specified with the flags for sending null characters or breaks. @@ -1755,7 +1769,7 @@ by a delay as in: # Wait for 5 seconds for exec to complete spawn telnet very.secure.gov sleep 5 - send password\\r + send password\er .fi .B exp_send @@ -1907,9 +1921,13 @@ be to reboot. If .I program -cannot be spawned successfully because exec(2) fails (e.g. when +cannot be spawned successfully because +.BR exec (2) +fails +(e.g., when .I program -doesn't exist), an error message will be returned by the next +doesn't exist), +an error message will be returned by the next .B interact or .B expect @@ -1986,7 +2004,7 @@ most recent non-info arguments given. changes terminal modes similarly to the external stty command. By default, the controlling terminal is accessed. Other terminals can -be accessed by appending "< /dev/tty..." to the command. (Note that +be accessed by appending "< /dev/tty...\&" to the command. (Note that the arguments should not be grouped into a single argument.) Requests for status return it as the result of the command. If no status @@ -2018,7 +2036,7 @@ scripts to avoid embedding passwords in stty \-echo send_user "Password: " - expect_user \-re "(.*)\\n" + expect_user \-re "(.*)\en" set password $expect_out(1,string) stty echo @@ -2053,7 +2071,7 @@ seconds since the epoch is returned. The .B \-format -flag introduces a string which is returned but with +flag introduces a string which is returned but with substitutions made according to the POSIX rules for strftime. For example %a is replaced by an abbreviated weekday name (i.e., Sat). Others are: @@ -2063,22 +2081,22 @@ weekday name (i.e., Sat). Others are: %b abbreviated month name %B full month name %c date-time as in: Wed Oct 6 11:45:56 1993 - %d day of the month (01-31) - %H hour (00-23) - %I hour (01-12) - %j day (001-366) - %m month (01-12) - %M minute (00-59) + %d day of the month (01\(en31) + %H hour (00\(en23) + %I hour (01\(en12) + %j day (001\(en366) + %m month (01\(en12) + %M minute (00\(en59) %p am or pm - %S second (00-61) - %u day (1-7, Monday is first day of week) - %U week (00-53, first Sunday is first day of week one) - %V week (01-53, ISO 8601 style) - %w day (0-6) - %W week (00-53, first Monday is first day of week one) + %S second (00\(en61) + %u day (1\(en7, Monday is first day of week) + %U week (00\(en53, first Sunday is first day of week one) + %V week (01\(en53, ISO 8601 style) + %w day (0\(en6) + %W week (00\(en53, first Monday is first day of week one) %x date-time as in: Wed Oct 6 1993 %X time as in: 23:59:59 - %y year (00-99) + %y year (00\(en99) %Y year as in: 1993 %Z timezone (or nothing if not determinable) %% a bare percent sign @@ -2098,7 +2116,7 @@ flag forces timestamp output to use the the local timezone is used. .TP .BI trap " [[command] signals]" -causes the given +causes the given .I command to be executed upon future receipt of any of the given signals. The command is executed in the global scope. @@ -2106,14 +2124,16 @@ If .I command is absent, the signal action is returned. If -.I command +.I command is the string SIG_IGN, the signals are ignored. If .I command is the string SIG_DFL, the signals are result to the system default. .I signals is either a single signal or a list of signals. Signals may be specified -numerically or symbolically as per signal(3). The "SIG" prefix may be omitted. +numerically or symbolically as per +.BR signal (3). +The "SIG" prefix may be omitted. With no arguments (or the argument \-number), .B trap @@ -2145,7 +2165,7 @@ command to return the largest signal num For example, the command "trap {send_user "Ouch!"} SIGINT" will print "Ouch!" each time the user presses ^C. -By default, SIGINT (which can usually be generated by pressing ^C) and +By default, SIGINT (which can usually be generated by pressing ^C) and SIGTERM cause Expect to exit. This is due to the following trap, created by default when Expect starts. .nf @@ -2161,7 +2181,7 @@ to start the interactive debugger. This .fi The debugger trap can be changed by setting the environment variable -EXPECT_DEBUG_INIT to a new trap command. +EXPECT_DEBUG_INIT to a new trap command. You can, of course, override both of these just by adding trap commands to your script. In particular, if you have your own "trap @@ -2268,7 +2288,7 @@ use syntax corresponding to earlier vers rationales are still valid and go into a lot more detail than this man page. .SH CAVEATS -Extensions may collide with Expect's command names. For example, +Extensions may collide with Expect's command names. For example, .B send is defined by Tk for an entirely different purpose. For this reason, most of the @@ -2289,7 +2309,7 @@ procedure you write that uses .BR expect . On the other hand, variables written are always in the local scope (unless a "global" command has been issued). The most common problem this causes -is when spawn is executed in a procedure. Outside the procedure, +is when spawn is executed in a procedure. Outside the procedure, .I spawn_id no longer exists, so the spawned process is no longer accessible simply because of scoping. Add a "global spawn_id" to such a procedure. @@ -2327,12 +2347,12 @@ variants and .BR interact ) use a heuristic to decide if the list is actually one argument or many. The heuristic can fail only in the case when the list actually -does represent a single argument which has multiple embedded \\n's +does represent a single argument which has multiple embedded \en's with non-whitespace characters between them. This seems sufficiently improbable, however the argument "\-nobrace" can be used to force a single argument to be handled as a single argument. This could conceivably be used with machine-generated Expect code. Similarly, --brace forces a single argument to be handle as multiple patterns/actions. +\-brace forces a single argument to be handle as multiple patterns/actions. .SH BUGS It was really tempting to name the program "sex" (for either "Smart EXec" @@ -2357,7 +2377,7 @@ Upgrade to IRIX 6.1. Telnet (verified only under SunOS 4.1.2) hangs if TERM is not set. This is a problem under cron, at and in cgi scripts, which do not -define TERM. Thus, you must set it explicitly - to what type is +define TERM. Thus, you must set it explicitly \(en to what type is usually irrelevant. It just has to be set to something! The following probably suffices for most cases. .nf @@ -2369,7 +2389,7 @@ following probably suffices for most cas Tip (verified only under BSDI BSD/OS 3.1 i386) hangs if SHELL and HOME are not set. This is a problem under cron, at and in cgi scripts, which do not define these environment variables. Thus, you must set -them explicitly - to what type is usually irrelevant. It just has to +them explicitly \(en to what type is usually irrelevant. It just has to be set to something! The following probably suffices for most cases. .nf @@ -2412,10 +2432,10 @@ the hardware is ready to receive input. both strategies: .nf - send "speed 9600\\r"; + send "speed 9600\er"; sleep 1 expect { - timeout {send "\\r"; exp_continue} + timeout {send "\er"; exp_continue} $prompt } @@ -2443,10 +2463,12 @@ shells, portably automating rlogin can b the prompt. A reasonable convention is to have users store a regular expression describing their prompt (in particular, the end of it) in the environment variable EXPECT_PROMPT. Code like the following -can be used. If EXPECT_PROMPT doesn't exist, the code still has a good chance of functioning correctly. +can be used. +If EXPECT_PROMPT doesn't exist, +the code still has a good chance of functioning correctly. .nf - set prompt "(%|#|\\\\$) $" ;# default prompt + set prompt "(%|#|\e\e$) $" ;# default prompt catch {set prompt $env(EXPECT_PROMPT)} expect \-re $prompt @@ -2504,8 +2526,8 @@ is ever moved around, you won't have to Newlines are usually converted to carriage return, linefeed sequences when output by the terminal driver. Thus, if you want a pattern that -explicitly matches the two lines, from, say, printf("foo\\nbar"), -you should use the pattern "foo\\r\\nbar". +explicitly matches the two lines, from, say, printf("foo\enbar"), +you should use the pattern "foo\er\enbar". .PP A similar translation occurs when reading from the user, via .BR expect_user . @@ -2558,43 +2580,43 @@ script. .br .I "Exploring Expect: A Tcl-Based Toolkit for Automating Interactive Programs" -\fRby Don Libes, pp. 602, ISBN 1-56592-090-2, O'Reilly and Associates, 1995. +\fRby Don Libes, pp.\& 602, ISBN 1-56592-090-2, O'Reilly and Associates, 1995. .br .I "expect: Curing Those Uncontrollable Fits of Interactivity" \fRby Don Libes, Proceedings of the Summer 1990 USENIX Conference, -Anaheim, California, June 11-15, 1990. +Anaheim, California, June 11\(en15, 1990. .br .I "Using .B expect to Automate System Administration Tasks" \fRby Don Libes, Proceedings of the 1990 USENIX Large Installation Systems Administration -Conference, Colorado Springs, Colorado, October 17-19, 1990. +Conference, Colorado Springs, Colorado, October 17\(en19, 1990. .br .I "Tcl: An Embeddable Command Language" \fRby John Ousterhout, Proceedings of the Winter 1990 USENIX Conference, -Washington, D.C., January 22-26, 1990. +Washington, D.C., January 22\(en26, 1990. .br .I "expect: Scripts for Controlling Interactive Programs" \fRby Don Libes, -Computing Systems, Vol. 4, No. 2, University of California Press Journals, +Computing Systems, Vol. 4, No.\& 2, University of California Press Journals, November 1991. .br .I "Regression Testing and Conformance Testing Interactive Programs", \fRby Don -Libes, Proceedings of the Summer 1992 USENIX Conference, pp. 135-144, -San Antonio, TX, June 12-15, 1992. +Libes, Proceedings of the Summer 1992 USENIX Conference, pp.\& 135\(en144, +San Antonio, TX, June 12\(en15, 1992. .br .I "Kibitz \- Connecting Multiple Interactive Programs Together", \fRby Don Libes, Software \- Practice & Experience, John Wiley & Sons, West Sussex, England, -Vol. 23, No. 5, May, 1993. +Vol. 23, No.\& 5, May, 1993. .br .I "A Debugger for Tcl Applications", \fRby Don Libes, -Proceedings of the 1993 Tcl/Tk Workshop, Berkeley, CA, June 10-11, 1993. +Proceedings of the 1993 Tcl/Tk Workshop, Berkeley, CA, June 10\(en11, 1993. .SH AUTHOR Don Libes, National Institute of Standards and Technology .SH ACKNOWLEDGMENTS @@ -2609,7 +2631,7 @@ and gave other assistance. .PP Design and implementation of .B Expect -was paid for in part by the U.S. government and is therefore in the public +was paid for in part by the U.S.\& government and is therefore in the public domain. However the author and NIST would like credit if this program and documentation or portions of them are used.