2024年6月14日(金) 16:30 Alain BROSSARD <abross...@reyl.com>: Even if the behavior of `set -a' is modified, your script (or the third-party script that you rely on?) is still broken when the user explicitly gives COLUMNS and LINES the export attribute, which is a *typical usage of those variables*. This should be a bug in the script expecting `ps ax' to not consider the environment COLUMNS.
---- > COLUMN is clearly meant to be an internal variable of bash given the > description of how it is used; What do you mean by ``the internal variable''? COLUMNS and LINES are traditionally variables to store the terminal width and height, and these are expected to be updated to have the correct values. Bash's behavior of updating COLUMNS and LINES after the termination of foreground jobs and SIGWINCH is consistent with that convention. Also, the behavior of the `ps' command honoring COLUMNS to format its output is also an expected one. The problem is that the script tries to used the ``formatted'' output of `ps ax' (specifically, column COMMAND) to extract information. I have to say it is typical to make COLUMNS and LINES environment variables. For the shell frameworks using those variables to work, those variables do not need to be exported. However, they need to be exported for CUI applications written in languages that don't provide a way to get the terminal width, such as AWK, and pure C without expecting POSIX's TIOCGSIZE. Then, users are expected to export those variables if the users want to use such programs. Actually the `ps' command is one of them. You can also observe this convention explicitly in the output of the `resize' command (provided by xterm). The `resize' command without arguments outputs the following text: $ resize COLUMNS=239; LINES=75; export COLUMNS LINES; which are expected to be used as $ eval "$(resize)" > Honestly, I don't know where to go with this issue. Bash's behavior > should be consistent and easily understood in order to have reliable > scripts. Clearly this case doesn't respect this. I'm not sure which one is more consistent, but exporting COLUMNS on checkwinsize seems also consistent with the POSIX requirement on `cd', `read', and other commands implicitly setting variables. The POSIX standard reads the ``assignments'' includes all the implicit changes to the variables, so it is consistent that the implicit change of COLUMNS by checkwinsize is also considered for `-a'. -- Koichi