Date: Thu, 13 Jun 2024 14:41:24 +0000 From: Alain BROSSARD via Bug reports for the GNU Bourne Again SHell <bug-bash@gnu.org> Message-ID: <zrap278mb05937863b28d9fefdcb7f948de...@zrap278mb0593.chep278.prod.outlook.com>
| 1. Bash with -a , under some conditions, exports to the environment | the variable COLUMNS which it shouldn’t That one is debatable as to being a bug. What POSIX says of "set -a" is: -a Set the export attribute for all variable assignments. When this option is on, whenever a value is assigned to a variable in the current shell execution environment, the export attribute shall be set for the variable. This applies to all forms of assignment, including those made as a side-effect of variable expansions or arithmetic expansions, and those made as a result of the operation of the cd, getopts, or read utilities. Note the "all forms of assignment" - it doesn't restrict that to assignments made as a direct result of the actions of the script. If before printing a prompt & reading a new command, bash were to query the terminal for its width, and assign the result to COLUMNS, then at least a plausible reading of that text might suggest that COLUMNS must be exported because of that. (It also makes the implementation simple, whenever assigning a value to a variable, check the -a flag state, if on, cause the variable to be exported). Personally, I suspect that were this ever to be taken to the POSIX people, then the result might be to restrict -a to variables the script writer (user) knows (or ought to know) will be affected by some command (or var-assign, which isn't really a command) and not to random others that the shell happens to set for its own purposes. But it depends upon what other shells do (if there are others that randomly set variables behind the user's back.) | 2. When COLUMNS is defined, ps behaves strangely That one I can't comment on, I have no idea which version of ps you're using. But do read its manual page (or whatever other doc exists) and make sure it isn't defined to use COLUMNS for some reason in your version. While COLUMNS is the width of the terminal, using it only when directing output to the terminal isn't necessarily (or even probably) the right thing to do, if it is to be used at all. kre