bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: set -a leads to truncated output from ps


From: Chet Ramey
Subject: Re: set -a leads to truncated output from ps
Date: Thu, 13 Jun 2024 11:43:38 -0700
User-agent: Mozilla Thunderbird

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    chet@case.edu    http://tiswww.cwru.edu/~chet/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]