Link to home
Start Free TrialLog in
Avatar of phoffric
phoffric

asked on

Centos 7 "set -x" causes a lot of stuff to appear in my terminal.

I just installed Centos 7, and I get too much stuff being output when I use set -x. Weird, huh?
$ set -x
++ __vte_prompt_command
+++ sed 's/^ *[0-9]\+ *//'
+++ HISTTIMEFORMAT=
+++ history 1
++ local 'command=set -x'
++ command='set -x'
++ local 'pwd=~'
++ '[' /home/admin/Tst '!=' /home/admin ']'
++ pwd='~/Tst'
+++ __vte_osc7
++++ __vte_urlencode /home/admin/Tst
++++ LC_ALL=C
++++ str=/home/admin/Tst
++++ '[' -n /home/admin/Tst ']'
++++ safe=/home/admin/Tst
++++ printf %s /home/admin/Tst
++++ str=
++++ '[' -n '' ']'
++++ '[' -n '' ']'

Open in new window

Furthermore, if I type any command, such as ls -l, I get the above stuff with some additional stuff which is possibly related to the specific command. To see the results of the command, I have to scroll up. So, please tell me how to get rid of this stuff and just in case this stuff can prove useful someday, how do I turn this stuff back on?

If I use a -x in a bash script or function in .bashrc, the stuff even spills out past the script.
Avatar of Nick Upson
Nick Upson
Flag of United Kingdom of Great Britain and Northern Ireland image

the command "set -x" causes the shell to echo all lines out before executing them, this is exactly as intended, to remove just do "set +x"
Issuing a set -x produces a line-by-line dump of every shell operation, so setting this will create a massive amount of output.

The purpose of set -x is to produces copious output for debugging.

Once you issue set -x, this output will continue till you issued set +x to disable tracing/debugging.

Keep in mind .bashrc has no scope like programming languages or maybe global scope, if you prefer... so you must issue set +x to disable this output.

Suggestion: Mention what you're trying to accomplish by enabling tracing/debugging for additional help.
Avatar of phoffric
phoffric

ASKER

I know about set +x.
In the past, I have run bash scripts with the -x option, or IIRC, set -x within the script, and got just the command lines printed out without all the extra stuff.
Are you both saying that if I want to debug a bashrc function or a bash script, I must get all the extra stuff?
SOLUTION
Avatar of Duncan Roe
Duncan Roe
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Much depends when and where you use set -x

You may have used set -x, but forgot to turn it off.

I.e. Surround the items of interest with set -x and set +x after when you want the debug features of interest to you.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
At work (RHEL 7.4), when I open my first window and type set -x, only two lines appeared - tolerable.
>> Try this: echo $PROMPT_COMMAND.
[user@localhost ~]$ echo $PROMPT_COMMAND
__vte_prompt_command

Open in new window

[root@localhost ~]# echo $PROMPT_COMMAND
printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"
[root@localhost ~]# set -x
++ printf '\033]0;%s@%s:%s\007' root localhost '~'

Open in new window

>>  unset PROMPT_COMMAND  What does a prompt command have to do with the big mess in the OP?
This resulted in nice behavior. How did you know?
How should this  be changed in /etc/profile.d/vte.sh ?
case "$TERM" in
  xterm*|vte*)
    [ -n "$BASH_VERSION" ] && PROMPT_COMMAND="__vte_prompt_command"
    [ -n "$ZSH_VERSION"  ] && precmd_functions+=(__vte_osc7)
    ;;

Open in new window

The unset command seemed to do the job. Thank you much.
rm /etc/profile.d/vte.sh
i rm vte.sh, and now I get after a restart, I get something new:
bash: a#: command not found...
bash: aliias: command not found...
Similar command is: 'alias'
bash: __vte_prompt_command: command not found...

Open in new window

I think I should have backed up that vte.sh as there were other things in it.
[user@localhost ~]$ set -x
++ __vte_prompt_command
++ local runcnf=1
++ local retval=127
++ [[ himxBH =~ i ]]
++ [[ ! -S /run/dbus/system_bus_socket ]]
++ [[ ! -x /usr/libexec/packagekitd ]]
++ [[ -n '' ]]
++ '[' 1 -eq 1 ']'
++ /usr/libexec/pk-command-not-found __vte_prompt_command
bash: __vte_prompt_command: command not found...
++ retval=127
++ return 127
[user@localhost ~]$ 

Open in new window

What do all these lines mean, and where do they come from?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks for pointing out the mispelling.

Now when I open a terminal or enter a cmd line, I get:
bash: __vte_prompt_command: command not found...

Open in new window

Turns out that I had saved the original vte file. So, I restored it, and am back to where I began in the OP.

I took a quick look at  /etc/profile.d/vte.sh, and now I see that all the stuff in the OP is from that file. Removing the file caused the above error even without the set -x, so what do you recommend?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for helping me get rid of this stuff.