bug-bash
[Top][All Lists]
Advanced

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

Re: it, soRE: set -a leads to truncated output from ps


From: Robert Elz
Subject: Re: it, soRE: set -a leads to truncated output from ps
Date: Fri, 14 Jun 2024 01:04:17 +0700

    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:  
<ZRAP278MB05937863B28D9FEFDCB7F948DEC12@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




reply via email to

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