Customize shell environment set and shopt

Source: Internet
Author: User

SET commandIt can be used to customize the shell environment and use the option "O" to enable or disable the option. For example, enable option: set-O option, and disable option: Set + O.

Shopt commandIs an alternative to the set command, which is the same as the SET command in many aspects, but it adds many options. You can use the "-P" option to view the shopt option settings. "-U" indicates a reset option, and "-s" indicates that the option is currently set.

Built-in set Command Options

Option name shortcut
Allexport-A automatically indicates the new or modified variables to be output from the setting of this option until the option is reset.
Braceexpand-B opens the curly extension, which is a default setting
Emacs uses the embedded editor of Emacs to edit command lines. It is a default setting.
Errexit-e exits when the command returns a non-zero exit status (failed. Not set when reading the initialization file
Histexpand-H is enabled when history replacement is executed! And !! Extension, which is a default setting
History opens the command line history, which is open by default
Ignoreeof prohibits you from using the EOF (CTRL + d) Key to exit shell. You must enter exit to exit. Equivalent to setting the shell variable ignoreeof = 10
Keyword-K places the keyword parameter in the command environment
Interactive-comments for interactive shell, the text following the # symbol is used as a comment
Monitor-M sets job control
Noclobber-C prevents file rewriting during redirection
Noexec-N read command, but not executed. Used to check the script syntax. Interactive running is not enabled
Noglob-D does not allow extension by path name. That is, the wildcard is disabled.
Notify the user when notify-B background job is completed
An error message is displayed when nounset-u extends an unspecified variable.
Onecmd-T exits after reading and executing commands
When you set physical-P, enter the CD or PWD to disable the symbolic link. Use physical directory instead
After privileged-P is set, the shell does not read the. profile or env file and does not inherit the shell function from the environment. The privilege is automatically enabled for the setuid script.
Verbose-V enables verbose mode for debugging
VI uses the VI built-in editor to edit command lines
Xtrace-X enables echo mode for debugging

Shopt Command Option

Option description
Cdable_vars if the parameter of the built-in command for CD is not a directory, it is assumed that it is a variable name, and the value of the variable is the directory to be converted
Cdspell corrects small spelling errors of directory names in the CD command. Check errors include characters in reverse order, missing characters, and repeated characters. If you know a change, the correct path will be printed and the command will continue. For Interactive Shell only
Checkhashbash searches the hash table before trying to execute a command to check whether the command exists. If the command does not exist, perform a normal path search.
Checkwinsizebash checks the window size after each command. If necessary, update the values of lines and columns.
Cmdhistbash tries to save all rows of a multi-line command in the same history item. This makes it easier to re-edit multi-line commands.
Dotglobbash includes a file name starting with a vertex (.) in the file name extension result.
Execfail if an interactive shell cannot execute a file that specifies the exec built-in command as a parameter, it will not exit. If exec fails, an interactive shell will not exit
The expand_aliases alias is extended. Enabled by default
Extglob enables extended pattern matching features (the normal expression metacharacters come from the file name extension of the Korn shell)
Histappend when shell exits, the history list will be added to the file named after the value of the histfile variable, instead of overwriting the file.
Histreedit if Readline is in use, the user has the opportunity to edit a failed historical replacement.
If histverify is set and Readline is in use, the historical replacement result is not passed to the shell parser immediately. Instead, it loads the result row into the Readline editing buffer and allows further modification.
If hostcomplete is set and readine is in use, bash tries to execute host name completion when a word containing @ is being completed. Enabled by default
Huponexit if set, when an interactive Login Shell exits, Bash will send a sighup (suspended signal) to all jobs
Interactive_comments in an interactive shell, the words starting with # and other characters in the same line can be ignored. Enabled by default
If lithist is enabled and the cmdhist option is also enabled, multiline commands are saved to history with embedded linefeeds, without the need to use semicolons to separate them wherever possible.
If mailwarn is set and bash is used to check whether the file of the email has been accessed since the last check, the message "the mail in mailfile has been read" is displayed"
If nocaseglob is set, bash matches the file name in case-insensitive mode when file name extension is executed.
If nullglob is set, bash allows the file name pattern that does not match any files to be extended into an empty string, rather than their own
If promptvars is set, the system prompts that the string has gone through variable and parameter extension after being extended. Enabled by default
Restricted_shell set this option if shell is started in restricted mode. This value cannot be changed. When executing the Startup File, you cannot reset this option to allow the Startup File to find whether the shell is restricted.
If sourcepath is set, the source built-in command uses the value of path to find the directory containing the files provided as parameters. Enabled by default
Synonym for source point (.)
Shift_verbose if this option is set, when the moving count exceeds the number of positional parameters, the shift built-in command will print an error message

The new option nocasematch has been introduced since version 3.1 of bash, which allows Bash to ignore case sensitivity when comparing styles.
Shopt-s nocasematch # open option

Customize shell environment set and shopt

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.