Bug 1707812 - bash -x switch induces absurd amount of unrelated execution output
Summary: bash -x switch induces absurd amount of unrelated execution output
Keywords:
Status: CLOSED DUPLICATE of bug 1578587
Alias: None
Product: Fedora
Classification: Fedora
Component: bash
Version: 30
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Siteshwar Vashisht
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-05-08 12:56 UTC by karl kleinpaste
Modified: 2019-05-10 13:05 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-05-10 13:05:26 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description karl kleinpaste 2019-05-08 12:56:05 UTC
Description of problem:
-x on scripts induces an absurd amount of excess output from internal commands having nothing whatever to do with the script itself.

perhaps this is actually the fault of bash-completion. i simply can't tell.

Version-Release number of selected component (if applicable):
bash-5.0.2-1.fc30

How reproducible:
always

Steps to Reproduce:
1. create a test script beginning with "#!/bin/bash -x".
   the more trivial, the better.
2. run the script.
3. observe mountains of useless output unrelated to the script's own triviality.

Actual results:

$ ls -l this-is-a-bash-bug 
-rwxr-xr-x 1 karl karl 23 May  8 08:36 this-is-a-bash-bug

$ cat this-is-a-bash-bug 
#!/bin/bash -x
echo hi

$ ./this-is-a-bash-bug 
+ unset _mlshdbg
+ '[' 0 = 1 ']'
+ export MODULES_RUN_QUARANTINE=LD_LIBRARY_PATH
+ MODULES_RUN_QUARANTINE=LD_LIBRARY_PATH
+ unset _mlre _mlIFS
+ '[' -n x ']'
+ _mlIFS=' 	
'
+ IFS=' '
+ for _mlv in ${MODULES_RUN_QUARANTINE:-}
+ '[' LD_LIBRARY_PATH = LD_LIBRARY_PATH -a LD_LIBRARY_PATH = LD_LIBRARY_PATH ']'
++ eval 'echo ${LD_LIBRARY_PATH+x}'
+++ echo
+ '[' -n '' ']'
+ _mlrv=MODULES_RUNENV_LD_LIBRARY_PATH
++ eval 'echo ${MODULES_RUNENV_LD_LIBRARY_PATH:-}'
+++ echo
+ _mlre='LD_LIBRARY_PATH='\'''\'' '
+ '[' -n 'LD_LIBRARY_PATH='\'''\'' ' ']'
+ _mlre='eval LD_LIBRARY_PATH='\'''\'' '
++ eval 'LD_LIBRARY_PATH='\'''\''' /usr/bin/tclsh /usr/share/Modules/libexec/modulecmd.tcl bash autoinit
+++ LD_LIBRARY_PATH=
+++ /usr/bin/tclsh /usr/share/Modules/libexec/modulecmd.tcl bash autoinit
+ _mlcode='_module_raw() {
   unset _mlshdbg;
   if [ "${MODULES_SILENT_SHELL_DEBUG:-0}" = '\''1'\'' ]; then
      case "$-" in
         *v*x*) set +vx; _mlshdbg='\''vx'\'' ;;
         *v*) set +v; _mlshdbg='\''v'\'' ;;
         *x*) set +x; _mlshdbg='\''x'\'' ;;
         *) _mlshdbg='\'''\'' ;;
      esac;
   fi;
   unset _mlre _mlIFS;
   if [ -n "${IFS+x}" ]; then
      _mlIFS=$IFS;
   fi;
   IFS='\'' '\'';
   for _mlv in ${MODULES_RUN_QUARANTINE:-}; do
      if [ "${_mlv}" = "${_mlv##*[!A-Za-z0-9_]}" -a "${_mlv}" = "${_mlv#[0-9]}" ]; then
         if [ -n "`eval '\''echo ${'\''$_mlv'\''+x}'\''`" ]; then
            _mlre="${_mlre:-}${_mlv}_modquar='\''`eval '\''echo ${'\''$_mlv'\''}'\''`'\'' ";
         fi;
         _mlrv="MODULES_RUNENV_${_mlv}";
         _mlre="${_mlre:-}${_mlv}='\''`eval '\''echo ${'\''$_mlrv'\'':-}'\''`'\'' ";
      fi;
   done;
   if [ -n "${_mlre:-}" ]; then
      eval `eval ${_mlre}/usr/bin/tclsh /usr/share/Modules/libexec/modulecmd.tcl bash '\''"$@"'\''`;
   else
      eval `/usr/bin/tclsh /usr/share/Modules/libexec/modulecmd.tcl bash "$@"`;
   fi;
   _mlstatus=$?;
   if [ -n "${_mlIFS+x}" ]; then
      IFS=$_mlIFS;
   else
      unset IFS;
   fi;
   unset _mlre _mlv _mlrv _mlIFS;
   if [ -n "${_mlshdbg:-}" ]; then
      set -$_mlshdbg;
   fi;
   unset _mlshdbg;
   return $_mlstatus;
};
module() { _module_raw "$@" 2>&1; };
MODULES_CMD=/usr/share/Modules/libexec/modulecmd.tcl; export MODULES_CMD;
MODULESHOME=/usr/share/Modules; export MODULESHOME;
test 0;'
+ _mlret=0
+ '[' -n x ']'
+ IFS=' 	
'
+ unset _mlIFS
+ unset _mlre _mlv _mlrv
+ '[' 0 -eq 0 ']'
+ eval '_module_raw() {
   unset _mlshdbg;
   if [ "${MODULES_SILENT_SHELL_DEBUG:-0}" = '\''1'\'' ]; then
      case "$-" in
         *v*x*) set +vx; _mlshdbg='\''vx'\'' ;;
         *v*) set +v; _mlshdbg='\''v'\'' ;;
         *x*) set +x; _mlshdbg='\''x'\'' ;;
         *) _mlshdbg='\'''\'' ;;
      esac;
   fi;
   unset _mlre _mlIFS;
   if [ -n "${IFS+x}" ]; then
      _mlIFS=$IFS;
   fi;
   IFS='\'' '\'';
   for _mlv in ${MODULES_RUN_QUARANTINE:-}; do
      if [ "${_mlv}" = "${_mlv##*[!A-Za-z0-9_]}" -a "${_mlv}" = "${_mlv#[0-9]}" ]; then
         if [ -n "`eval '\''echo ${'\''$_mlv'\''+x}'\''`" ]; then
            _mlre="${_mlre:-}${_mlv}_modquar='\''`eval '\''echo ${'\''$_mlv'\''}'\''`'\'' ";
         fi;
         _mlrv="MODULES_RUNENV_${_mlv}";
         _mlre="${_mlre:-}${_mlv}='\''`eval '\''echo ${'\''$_mlrv'\'':-}'\''`'\'' ";
      fi;
   done;
   if [ -n "${_mlre:-}" ]; then
      eval `eval ${_mlre}/usr/bin/tclsh /usr/share/Modules/libexec/modulecmd.tcl bash '\''"$@"'\''`;
   else
      eval `/usr/bin/tclsh /usr/share/Modules/libexec/modulecmd.tcl bash "$@"`;
   fi;
   _mlstatus=$?;
   if [ -n "${_mlIFS+x}" ]; then
      IFS=$_mlIFS;
   else
      unset IFS;
   fi;
   unset _mlre _mlv _mlrv _mlIFS;
   if [ -n "${_mlshdbg:-}" ]; then
      set -$_mlshdbg;
   fi;
   unset _mlshdbg;
   return $_mlstatus;
};
module() { _module_raw "$@" 2>&1; };
MODULES_CMD=/usr/share/Modules/libexec/modulecmd.tcl; export MODULES_CMD;
MODULESHOME=/usr/share/Modules; export MODULESHOME;
test 0;'
++ MODULES_CMD=/usr/share/Modules/libexec/modulecmd.tcl
++ export MODULES_CMD
++ MODULESHOME=/usr/share/Modules
++ export MODULESHOME
++ test 0
+ '[' 0 = 1 ']'
+ '[' -t 2 ']'
+ export -f _module_raw
+ export -f module
+ export -f switchml
+ ENV=/usr/share/Modules/init/profile.sh
+ export ENV
+ BASH_ENV=/usr/share/Modules/init/bash
+ export BASH_ENV
+ '[' 5 -ge 3 ']'
+ [[ hxB =~ i ]]
+ [[ ! :.:/home/karl/bin/x86_64/.private:/home/karl/bin/x86_64:/home/karl/bin:/usr/local/sbin:/usr/sbin:/usr/local/bin:/usr/bin: =~ :/usr/share/Modules/bin: ]]
+ PATH=/usr/share/Modules/bin:.:/home/karl/bin/x86_64/.private:/home/karl/bin/x86_64:/home/karl/bin:/usr/local/sbin:/usr/sbin:/usr/local/bin:/usr/bin
+ export PATH
+ '[' '!' -n x ']'
++ manpath
+ [[ ! :/usr/local/man:/usr/local/share/man:/usr/share/man:: =~ :/usr/share/man: ]]
+ unset _mlcode _mlret
+ '[' -n '' ']'
+ echo hi
hi

Expected results:
$ ./this-is-a-bash-bug 
+ echo hi
hi

Additional info:

i would have chosen severity as low, but the number of areas where -x is useful to me makes me choose medium, wondering whether high is in order.

in all seriousness, what is bash doing, that it is executing *anything* other than my script's commands?
what guarantees do i have that whatever bash is also doing will not interfere with my script's behavior?

Comment 1 Kamil Dudka 2019-05-10 12:30:40 UTC
This looks like a duplicate of bug #1578587.

Comment 2 karl kleinpaste 2019-05-10 12:54:56 UTC
so it is. thanx.

reported just about exactly a year ago, with zero actual progress on it, as f28 goes EOL when that bug will be auto-closed.

so i've just done "dnf erase environment-modules --noautoremove" which got rid of
 environment-modules 4ti2 Macaulay2 scl-utils

Comment 3 Kamil Dudka 2019-05-10 13:05:26 UTC
Thanks for confirmation!  I have moved the other bug to f30 to prevent it from being auto-closed.

*** This bug has been marked as a duplicate of bug 1578587 ***


Note You need to log in before you can comment on or make changes to this bug.