See the help

set --help

View the flags that have been set

$ echo  $-
himBHs

Set the flag

set -flag

Unset Flag

set +flag

Check the use-oSet the flag

$ set -o allexport off braceexpand on emacs on errexit off errtrace off functrace off hashall on histexpand on history on ignoreeof off interactive-comments on keyword off monitor on noclobber off noexec off noglob off nolog off notify off  nounset off onecmd off physical off pipefail off posix off privileged off verbose off vi off xtrace off

use-oSet the flag

# For example, the set -o view is changed to on set -o history

use+oUnset Flag

# set +o history = off set +o history

set -v

Displays the input values read by the shell, and then displays the output

$ set -v
$ ls
ls
test1  test2
$ echo 123
echo 123
123

set -x

Enable script debugging

The value of the expanded intermediate variable will be printed directly below. There is no need for additional printing

/ / # test6 file! /usr/bin/bash set -x a=$1 b=$2 $ ./test6 q ewr er + ./test6 q ewr er + a=q + b=ewr

set —

The original position parameter unset(equivalent to empty) is set first.

// File test5 #! /usr/bin/bash set -- echo $0 echo $1 echo $2 echo $3 $./test5 zz xx cc./test5

${1}, ${2}… ${1}, ${2}, ${2}…

// File test5 #! /usr/bin/bash set -- QQ ww echo $0 echo $1 echo $2 echo $3 $./test5./test5 QQ ww $./test5 zz xx cc./test5 qq ww // ${3} $./test5 zz xx cc./test5 qq ww // ${3} $./test5 zz xx cc

set –

If there is no parameter after set -, the original position parameter remains unchanged and reads normally. -x and -v will be turned off if they have been set.

// File test5 #! /usr/bin/bash set - echo $0 echo $1 echo $2 echo $3 $ ./test5 zz xx cc ./test5 zz xx cc

If set – is followed by an argument, the original position parameter is unset(empty).

// File test5 #! /usr/bin/bash set - qq echo $0 echo $1 echo $2 echo $3 $ ./test5 zz xx cc ./test5 qq

reference

  • Bash Reference Manual:https://www.gnu.org/software/…