Bash Shell - 使用内置的set和shopt命令设置bash选项
来源:互联网 发布:男人越大越好吗知乎 编辑:程序博客网 时间:2024/06/06 05:48
本文转载至:http://blog.csdn.net/yuast1234/article/details/5686871
使用内置的set和shopt命令设置bash选项
set命令可以用来定制shell环境,使用选项“o”来打开或者关闭选项。例如打开选项:set -o 选项,关闭选项目:set +o 选项。
例如要打开vi交互式命令行编辑,则如下:
[root@localhost ~]# 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
[root@localhost ~]# set -o vi #把vi选项打开
[root@localhost ~]# set -o #查看当前设置情况
allexport off
braceexpand on
emacs off
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 on #已经打开
xtrace off
内置set命令选项
选项名快捷开关含义allexport-a从这个选项中被设置开始就自动标明要输出的新变量或修改过的变量,直至选项被复位braceexpand-B打开花括号扩展,它是一个默认设置emacs 使用emacs内置编辑器进行命令行编辑,是一个默认设置errexit-e当命令返回一个非零退出状态(失败)时退出。读取初始化文件时不设置histexpand-H执行历史替换时打开!和!!扩展,是一个默认设置history 打开命令行历史、默认为打开ignoreeof 禁止用EOF(Ctrl+D)键退出shell。必须键入exit才能退出。等价于设置shell变量IGNOREEOF=10keyword-k将关键字参数放到命令的环境中interactive-comments 对于交互式shell,把#符后面的文本作为注释monitor-m设置作业控制noclobber-C防止文件在重定向时被重写noexec-n读命令,但不执行。用来检查脚本的语法。交互式运行时不开启noglob-d禁止用路径名扩展。即关闭通配符notify-b后台作业完成时通知用户nounset-u扩展一个未设置的变量时显示一个错误信息onecmd-t在读取和执行命令后退出physical-P设置时,在键入cd或pwd禁止符号链接。用物理目录代替privileged-p设置后,shell不读取.profile或ENV文件,且不从环境继承shell函数,将自动为setuid脚本开启特权verbose-v为调试打开verbose模式vi 使用vi内置编辑器进行命令行编辑xtrace-x为调试打开echo模式
[root@localhost ~]# shopt -p #查看当前设置情况
shopt -u cdable_vars
shopt -u cdspell
shopt -u checkhash
shopt -s checkwinsize
shopt -s cmdhist
shopt -u dotglob
shopt -u execfail
shopt -s expand_aliases
shopt -u extdebug
shopt -u extglob
shopt -s extquote
shopt -u failglob
shopt -s force_fignore
shopt -u gnu_errfmt
shopt -u histreedit
shopt -u histappend
shopt -u histverify
shopt -s hostcomplete
shopt -u huponexit
shopt -s interactive_comments
shopt -u lithist
shopt -s login_shell
shopt -u mailwarn
shopt -u no_empty_cmd_completion
shopt -u nocaseglob
shopt -u nullglob
shopt -s progcomp
shopt -s promptvars
shopt -u restricted_shell
shopt -u shift_verbose
shopt -s sourcepath
shopt -u xpg_echo
[root@localhost ~]# shopt -s cdspell #把cdspell选项打开
[root@localhost ~]# shopt -p cdspell #打印cdspell设置
shopt -s cdspell
[root@localhost ~]# cd /raot #故意拼写错误
/root
[root@localhost ~]# pwd #查看当前目录
/root
[root@localhost ~]# cd /usr/loca/bin #故意拼写错误
/usr/local/bin
[root@localhost bin]# pwd #查看当前目录
/usr/local/bin
[root@localhost bin]# shopt -u cdspell #把cdspell选项打开
[root@localhost bin]# shopt -p cdspell #打印cdspell设置
shopt -u cdspell
[root@localhost bin]# cd /raot #故意拼写错误
-bash: cd: /raot: 没有那个文件或目录 #进入目录错误
- Bash Shell-使用内置的set和shopt命令设置bash选项
- Bash Shell-使用内置的set和shopt命令设置bash选项
- Bash Shell-使用内置的set和shopt命令设置bash选项
- Bash Shell-使用内置的set和shopt命令设置bash选项
- Bash Shell - 使用内置的set和shopt命令设置bash选项
- Bash Shell-使用内置的set和shopt命令设置bash选项
- 【Bash百宝箱】shell内建命令之set、shopt
- Bash中的shopt选项
- bash shell内置命令
- 关于LINUX shell环境设置命令set 和 shopt
- 关于trap ERR的一个bash shell set 参数之二:shopt -s extdebug
- BASH shell set命令详解
- BASH shell set命令详解
- BASH shell set命令详解
- Linux bash shell中变量的设置和使用
- linux bash shell set 命令详解
- bash之shopt
- 【BASH】bash shell的使用实例
- 读写一个cookie
- Android下载管理DownloadManager功能扩展和bug修改
- 自动开启GPS服务
- SourceInsight使用技巧
- Java GC系列(1):Java垃圾回收简介
- Bash Shell - 使用内置的set和shopt命令设置bash选项
- **(leetcode) (tree) Path Sum II
- Android自动滚动 轮播循环的ViewPager
- 第十三周项目1:数组大折腾(1)
- Linux内存管理之mmap详解
- Linux touch 使用详解
- vc2010 一运行整个项目查找就卡死情况!
- hbase filter练习
- 深度探索C++对象模型