Impostare le opzioni della BASH con Shopt

Mattepuffo's logo
Impostare le opzioni della BASH con Shopt

Impostare le opzioni della BASH con Shopt

Shopt è un comando builtin che ci permette di attivare / disattivare diverse opzioni della BASH.

Per vedere le opzioni correnti basta dare il comando:

$ shopt
autocd         	off
assoc_expand_once	off
cdable_vars    	off
cdspell        	off
checkhash      	off
checkjobs      	off
checkwinsize   	on
cmdhist        	on
compat31       	off
compat32       	off
compat40       	off
compat41       	off
compat42       	off
compat43       	off
compat44       	off
complete_fullquote	on
direxpand      	off
dirspell       	off
dotglob        	off
execfail       	off
expand_aliases 	on
extdebug       	off
extglob        	off
extquote       	on
failglob       	off
force_fignore  	on
globasciiranges	on
globstar       	off
gnu_errfmt     	off
histappend     	off
histreedit     	off
histverify     	off
hostcomplete   	on
huponexit      	off
inherit_errexit	off
interactive_comments	on
lastpipe       	off
lithist        	off
localvar_inherit	off
localvar_unset 	off
login_shell    	off
mailwarn       	off
no_empty_cmd_completion	off
nocaseglob     	off
nocasematch    	off
nullglob       	off
progcomp       	on
progcomp_alias 	off
promptvars     	on
restricted_shell	off
shift_verbose  	off
sourcepath     	on
xpg_echo       	off

Per impostare un' opzione:

$ shopt -s autocd
$ Desktop/
cd -- Desktop/
~/Desktop$ 

Come vedete l'opzione viene attivata subito; nel caso specifico, autocd serve per spostarsi tra le cartelle senza usare il comando cd.

Per disattivare l'opzione:

$ shopt -u autocd
~/Desktop$ Desktop
bash: Desktop: comando non trovato

Come vedete adesso non funziona più.

Per avere le opzioni abilitate/disbilitate dal boot, dovete mettere il comando dentro al .bashrc.

Enjoy!


Condividi

Commentami!