Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to undo "set -x" in unix shell?

Tags:

shell

unix

In following some random directions on the internet, trying to debug an issue of mine at a shell (I use zsh), I ran set -x. Thanks to this I figured out my issue. However, I'm now in an awkward position of not knowing how to turn this debugging off -- I really don't even understand what I did in the first place, you see.

I also figured out that I could just do zsh and get a new shell. The obvious unset -x does not work. I would like to know the correct way. Thanks!

Update:

Found this unix&linux stack exchange post about what -x does. Still don't know how to turn it off.

like image 628
Brian Peterson Avatar asked Aug 07 '14 00:08

Brian Peterson


People also ask

How do you undo set in X?

$ set +x # is the opposite of set -x, and will reverse what you typed.

How do I turn off set X in Linux?

It can be enabled on the command line or on the sh-bang line by providing -x or by the set -x statement. It can be disabled using the set +x statement.

What is set X in Unix?

The set -x command is used to debug bash script where every executed statement is printed to the shell for debugging or troubleshooting purposes. The set -x command can be directly executed in an interactive bash shell or can be used inside the bash script.

How do I undo set O VI?

Undo changes in vim / ViType u to undo the last change. To undo the two last changes, you would type 2u . Press Ctrl-r to redo changes which were undone.


1 Answers

You can use set +x to switch it back. The output of help set describes this:

$ help set
set: set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
    ...
    -v  Print shell input lines as they are read.
    -x  Print commands and their arguments as they are executed.
    ...

Using + rather than - causes these flags to be turned off.  The
flags can also be used upon invocation of the shell.  The current
set of flags may be found in $-.  The remaining n ARGs are positional
parameters and are assigned, in order, to $1, $2, .. $n.  If no
ARGs are given, all shell variables are printed.

Note the “Using + rather than - causes these flags to be turned off” part.

like image 95
andrewdotn Avatar answered Sep 20 '22 13:09

andrewdotn