[Top][All Lists]

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

Re: (enhancement request) Limiting depth of xtrace enabled

From: Piotr Grzybowski
Subject: Re: (enhancement request) Limiting depth of xtrace enabled
Date: Sun, 6 May 2018 16:09:02 +0200


 I kind of like it. It also bothered me from time to time, not in the case of 
lmod though.
 I enclose the patch. Note that it does not work with depth of functions, since 
it is not the way xtrace subsystem prints the levels. Different patch is needed 
if you want to control function frames depth.
 I am not not familiar with lmod, I tested with:

  eval `$LMOD_CMD sh "$@"`

although I am not sure about the logic of those scripts in 
Lmod-7.7.tar.bz2:./init and at first glance I do not like this eval, the patch 
will make bash behave in this case as you need (as far as I could tell).


Attachment: set_o_xtrace_levels_with_env_XTRACE_DEPTH.patch
Description: Binary data

On 5 May 2018, at 17:36, Carl Ponder wrote:

> (I'm sending this request to bug-bash since that's what the GNU/bash 
> documention said to do.
> I'm also CC'ing the lmod-users community since this would be of interest to 
> them.
> I don't know how broadly you would want to reply to this.)
> I use #!/bash -eux in almost all my scripts, so I can quickly figure out if 
> they were doing anything wrong.
> Using "modules", though, I hit a problem that the module commands all print 
> out huge amounts of output from the environment settings they make.
> The problem is that "regular" linux commands just print out like
>   + ls
> but the module command is an alias to a bash function, so all its contents 
> are traced as well.
> My current workaround is to redefine module (Lmod version) as this
>   function module
>   {   set +o xtrace; eval $($LMOD_CMD bash "$@") && eval
>   $(${LMOD_SETTARG_CMD:-:} -s sh); errcode=$?; set -o xtrace; return
>   $errcode; }
> which temporarily suspends the xtrace output and only prints out these extras
>   + module load pgi
>   *+ set +o xtrace**
>   **+ return 0*
>   + module list
> I can live with this, but it's still a mess to explain to modules/Lmod users.
> As far as I can tell, there's no real workaround in the modules/Lmod 
> implementations since direct shell operations are the only way they can work.
> On the bash side, though, a solution would be to limit the "depth" to which 
> the xtrace setting would apply, so I could trace my top-level commands but 
> not the contents of function calls, or only function calls up to a certain 
> depth.
> A syntax like this would be ok
> export XTRACE_DEPTH=1
> Would you consider it as an enhancement?

reply via email to

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