Bash $(...) DISPLAYS EVERY COMMAND

I use things like this a lot in ksh and bash, but lately bash has been printing the command for every loop:

... | while read f
do
if [ "$(cmp $f xx/$f 2>&1)" = "" ]
then
 echo Differ "$f"
fi
done

How to prevent this?

Hints: -x or -v as arguments to the shell

So... perhaps you didn't mean to have those arguments set... so it's possible the shell is defaulting to this elsewhere. Or perhaps somebody did something like a "set -x" from the command line. So you can try doing "set -" (set dash) to see if that fixes things.

No, this just applies to the subshell of the (...). Here is another example, with first page of screen output:

$ (cd GnuCash ; find * -type f|while read f; do  fi [ ! -s ~/GnuCash2/"$f" ]thencp -p "$f" ~/GnuCash2/"$f";continuefid="$(cmp "$f" ~/GnuCash2/"$f" 2>&1)";  if [ "$d" != "" ];  then   echo Differ: "$d";ls -ld "$f" ~/GnuCash2/"$f";  fi; done)2>&1|pg























cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
Differ: ubuntu-DGPickett.gnucash /home/dgp/GnuCash2/ubuntu-DGPickett.gnucash differ: byte 13, line 1
-rw-rw-r-- 1 dgp dgp 1345098 Jan 30 15:04 /home/dgp/GnuCash2/ubuntu-DGPickett.gnucash
-rw-rw-r-- 1 dgp dgp 1347820 Feb  1 13:12 ubuntu-DGPickett.gnucash
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
:

You can see it is a pretty worthless thing to do, too!

Lots of typos in what you had... just to make sure, could you either edit your post or submit correction to clean things up a bit?

I second this. If i remember correctly bash first reads the /etc/bashrc and only then the rc-file in the own $HOME. Might it be that somehow the subshells only use one of these and hence operate with a different configureation than your login shell(s)?

I hope this helps.

bakunin

The

shopt -q 

builtin lets you test which options are in effect. Read this discussion which is too long for display here.

https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html\#The-Shopt-Builtin

....Instead of shooting in the dark. Then you can eliminate set -[some option ] as a problem