Thanks Chet, Your explanation is crystal clear and shows how bash follows its documentation and vice versa. However, how many users of bash in the world could have this understanding of how set -a, checkwinsize and COLUMNS interact with each causing "PS" to change its behavior in mid-flight (so to speak). In my case, this behavior breaks at least half-dozen scripts which are provided by a third-party just because I called grep in the site configuration script. I do retract the fact that this is a bug, but this is still not really an acceptable behavior from my point of view. COLUMN is clearly meant to be an internal variable of bash given the description of how it is used; checkwinsize is automatically set and probably unknown to 99% of bash script writers as is the fact that an external command, grep in my case, will impact the behavior of ps if called within -a. Add to this that it is extremely difficult to check whether -a is set or not without using an external command.
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 would suggest to put LINES and COLUMN out of scope of the behavior of "set -a", or at the very least make all these interactions explicit within the man page. If it had been documented, I would have saved myself many hours of work as I did read the documentation once I had pinned down that "set -a" is the command which caused those script to fail. Though the real culprit, in the end, might be checkwinsize default behavior if one wanted to blame a single member of this trio. Regards, Alain Brossard Alain BROSSARD System & Network Administrator Technology D +41 22 816 8607 M +41 79 612 2336 T +41 22 816 8600 F +41 22 816 8009 abross...@reyl.com REYL & Cie SA Rue du Rhône 4 1204 Genève www.reyl.com The information contained in email messages from REYL & Cie SA may contain confidential, proprietary or legally privileged information and is intended only for the use of the addressee named above. No confidentiality or privilege is waived or lost by any mis-transmission. If you are not the addressee of this email message, you must not use, distribute, copy it in any form or take any action in reliance on it. If you have received this email message by error, please notify us immediately by replying to the message and delete it from your computer. If there are any attachments to the email messages that you received in error, kindly refrain from opening them and do not download or save them to your computer. In accordance with industry standards and practices, and to comply with our legal and regulatory retention requirement REYL & Cie SA monitors and retains email messages for a period of time in accordance with its policies, guidelines and procedures. Email transmission cannot be guaranteed to be secured or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. REYL & Cie SA is not liable for any unproper or incomplete transmission of the information contained in email messages or for any delay it their receipt. Some publications included in email message may be advertising material (pursuant to Art. 68 of the Federal Act on Financial Services, Financial Services Act of 15 June 2018) for financial services or for financial instruments. For any financial instruments mentioned, we will be happy to provide you with additional documents at any time and free of charge, such as a key information document pursuant to Art. 58 et seq. of the Financial Services Act, a prospectus pursuant to Art. 35 et seq. of the Financial Services Act or an equivalent foreign product information sheet, e.g. a basic information sheet pursuant to Regulation EU 1286/2014 for packaged investment products for retail investors and insurance investment products (PRIIPS KID). We consider your inquiries about our products and services as a request to contact you and send you relevant information. -----Original Message----- From: Chet Ramey <chet.ra...@case.edu> Sent: Thursday, June 13, 2024 8:44 PM To: Alain BROSSARD <abross...@reyl.com>; Andreas Schwab <sch...@linux-m68k.org>; Alain BROSSARD via Bug reports for the GNU Bourne Again SHell <bug-bash@gnu.org> Cc: chet.ra...@case.edu Subject: Re: set -a leads to truncated output from ps On 6/13/24 1:45 PM, Alain BROSSARD via Bug reports for the GNU Bourne Again SHell wrote: > Hi Andreas, > > Sure, the variables explicitly assigned to get exported, that is the > expected behavior. > But there is nothing which explains why the variable COLUMNS becomes an > environment variable. OK. The description of COLUMNS says: COLUMNS Used by the select compound command to determine the terminal width when printing selection lists. Automatically set if the checkwinsize option is enabled or in an interactive shell upon receipt of a SIGWINCH. > > Run “ps ax” twice and the results of the second execution is different > from the first if and only if “set -a” was called fiirst. This is NOT an > expected behavior. You have checkwinsize set. The description of checkwinsize reads: checkwinsize If set, bash checks the window size after each external (non-builtin) command and, if necessary, updates the values of LINES and COLUMNS. This option is enabled by default. So the first invocation of ps, since it's a non-builtin command, makes bash query the terminal and adjust LINES and COLUMNS. > Do the following and you won’t get a problem: > > set -a > var1=xx > var2=xx > set +a All builtin commands. > All is fine, but do the following and COLUMNS gets exported: > > set -a > echo $PATH | grep xxx/scripts || PATH=${PATH}:/newdir > ps ax is now truncated, definitely NOT expected The value of COLUMNS gets modified, and auto-exported since you have `set -a' enabled. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/