Anonymous | Login | 2024-10-15 00:35 UTC |
Main | My View | View Issues | Change Log | Docs |
Viewing Issue Simple Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||
ID | Category | Severity | Type | Date Submitted | Last Update | ||
0001532 | [Issue 8 drafts] Shell and Utilities | Objection | Error | 2021-11-03 14:15 | 2024-06-11 09:12 | ||
Reporter | stephane | View Status | public | ||||
Assigned To | |||||||
Priority | normal | Resolution | Accepted As Marked | ||||
Status | Closed | Product Version | Draft 2.1 | ||||
Name | Stephane Chazelas | ||||||
Organization | |||||||
User Reference | 0001053 | ||||||
Section | stty utility | ||||||
Page Number | |||||||
Line Number | |||||||
Final Accepted Text | Note: 0005655 | ||||||
Summary | 0001532: "stty -g" output should not have to be split | ||||||
Description |
The resolution of 0001053, about the specification of "stty -g" changes: -g Write to standard output all the current settings in an unspecified form that can be used as arguments to another invocation of the stty utility on the same system. The form used shall not contain any characters that would require quoting to avoid word expansion by the shell; see Section 2.6 (on page 2353). to: -g Write to standard output all the current settings, optionally excluding the terminal window size, in an unspecified form that, when used as arguments to another invocation of the stty utility on the same system, attempts to apply those settings to the terminal. The form used shall not contain any sequence that would form an Informational Query, nor any characters that would require quoting to avoid word expansions, other than field splitting, by the shell; see Section 2.6 (on page 2353). While the 2018 edition had: -g Write to standard output all the current settings in an unspecified form that can be used as arguments to another invocation of the stty utility on the same system. The form used shall not contain any characters that would require quoting to avoid word expansion by the shell; see wordexp. It's one stream of bytes that applications send to standard output. For that stream of bytes to be "used as argument*S* to another invocation of the stty utility", it implies that that output should somehow be split into a list of arguments (and also implies the result fits in the ARG_MAX limit and doesn't contain NUL bytes). The reference to 2.6 suggests maybe "sh" should be involved to perform that splitting. It almost suggests that the output should be appended to "stty ", or possibly "stty -- " and fed to sh as in (printf "stty -- "; stty -g) | sh AFAIK, stty -g was introduced in SysIII circa 1980. It was outputting on word on one line made of a ":"-separated of alnums from the portable charset and followed by a newline character. After it was specified by POSIX, it was also added to BSDs (some 4.3 variant), with "=" in the list of characters that may occur (not in leading position) in the ":"-delimited list. GNU stty has used a format similar to SysIII from at least as far back as 1990. The way to save and restore it was always to store that output without the trailing newline characters, which in a shell can be done with: saveterm=$(stty -g) And to restore it: stty "$saveterm" The "--" being unnecessary because the output of stty -g never starts with "-" and with some (including GNU stty) not allowed. All the documentations of stty I've seen talk of *one* (an) argument to be passed to stty. They don't say the output may (let alone should) be split in any way to be passed as several arguments to stty. In the unlikely event that there are indeed stty implementations that require the output of stty -g to be split into arguments before being fed back to stty, we'd need to specify how those are meant to be split. |
||||||
Desired Action |
Change the description of the -g option to something like: -g Write to standard output all the current settings, optionally excluding the terminal window size, in an unspecified form that, when stripped of trailing newline characters, and used as the one and only argument to another invocation of the stty utility on the same system, attempts to apply those settings to the terminal. The form used shall consist of one line of text consisting of only printable characters from the portable character set, excluding whitespace characters, NUL, and all characters that are special in the syntax of the sh language (`"$&*()[]{};'#~?<>\|). (alternatively, specify it as the ^[[:alnum:]][[:alnum:]=]*:[[:alnum:]=:]*\n extended regexp in the C locale.) A clarifying example would help like: saveterm=$(stty -g) and: [ -n "$saveterm" ] && stty "$saveterm" [ -n "$saveterm" ] && stty $saveterm eval "${saveterm:+stty $saveterm}" Are three ways the settings may be restored, the first one being the canonical one and the last one assuming none of the characters allowed in the stty -g output are currently present in $IFS (and therefore not recommended). The example should be changed to saveterm=$(stty −g) # save terminal state restoresize=$( stty size | awk '{printf "stty rows %d cols %d", $1, $2}' ) # save terminal size stty new settings # set new state ... [ -n "$saveterm" ] && stty "$saveterm" # restore terminal state eval "$ttysize" # restore terminal size Also using awk instead of shell IFS-splitting+globbing as as discussed on the mailing list, $IFS is not guaranteed to contain all the blank characters in the locale (and anyway yash is the only shell that considers multi-byte blanks as IFS-whitespace-characters wrt IFS-splitting), while awk is required to split fields on blanks (even though not all implementations do). |
||||||
Tags | issue8 | ||||||
Attached Files | |||||||
|
Relationships | ||||||
|
Issue History | |||
Date Modified | Username | Field | Change |
2021-11-03 14:15 | stephane | New Issue | |
2021-11-03 14:15 | stephane | Name | => Stephane Chazelas |
2021-11-03 14:15 | stephane | User Reference | => 0001053 |
2021-11-03 14:15 | stephane | Section | => stty utility |
2021-11-03 14:23 | stephane | Note Added: 0005513 | |
2021-11-03 14:51 | stephane | Note Added: 0005514 | |
2021-11-03 14:51 | stephane | Note Edited: 0005514 | |
2021-11-03 16:01 | stephane | Note Added: 0005515 | |
2021-11-03 16:04 | stephane | Note Added: 0005516 | |
2022-02-03 16:47 | geoffclare | Note Added: 0005655 | |
2022-02-03 16:48 | geoffclare | Note Edited: 0005655 | |
2022-02-03 16:49 | geoffclare | Note Edited: 0005655 | |
2022-02-03 16:50 | geoffclare | Final Accepted Text | => Note: 0005655 |
2022-02-03 16:50 | geoffclare | Status | New => Resolved |
2022-02-03 16:50 | geoffclare | Resolution | Open => Accepted As Marked |
2022-02-03 16:50 | geoffclare | Tag Attached: issue8 | |
2022-02-03 19:04 | kre | Note Added: 0005659 | |
2022-02-04 09:35 | geoffclare | Note Added: 0005661 | |
2022-02-24 11:52 | geoffclare | Status | Resolved => Applied |
2023-05-03 10:32 | geoffclare | Relationship added | related to 0001687 |
2024-06-11 09:12 | agadmin | Status | Applied => Closed |
Mantis 1.1.6[^] Copyright © 2000 - 2008 Mantis Group |