Questions tagged [shopt]

Shell Options dictate how the shell application behaves and responds to the user commands.

Filter by
Sorted by
Tagged with
1
vote
1answer
34 views

Which bash shell options are used by the parser?

Restricting our focus exclusively to bash, in this answer on Stack Overflow it is reported the following. extglob is a flag used by the parser. Functions, compound commands, &c. are parsed in ...
0
votes
1answer
40 views

Does setting the bash shell option 'checkhash' actually improve the performance of bash commands?

Premise: In the process of modifying .bashrc, and going through the bash manual for shopt online page for the different shell options that can be handled by shopt, I came across the option checkhash, ...
1
vote
1answer
108 views

Why does shopt -s nullglob remove a string with question mark in an array element?

This little setting drove me crazy: shopt -s nullglob I use it in my bash 4.3 script as a global setting to avoid errors scanning empty directories. Now I found a strange problem which I do not ...
9
votes
1answer
492 views

Setting bash options in a compound command

I have found that setting the extglob shell option within a compound compound results in failure of subsequent anti-globs. Are shell options required to be set outside of compound commands? I did not ...
1
vote
0answers
38 views

Cannot enable shopt extglob from bash command string argument? (temporarily set shopt extglob) [duplicate]

I'm using bash version: $ bash --version GNU bash, version 4.4.23(1)-release (x86_64-pc-msys) So, say I have these files: $ ls a.txt aa b.txt bb README Say, I want to list anything but aa; (...
1
vote
1answer
109 views

shopt -s cdable_vars is not expanding as expected

In my cluster (I don't have root access of it), I have defined in my .bashrc: shopt -s cdable_vars shopt -s direxpand export s13=/c13scratch/rudrab I am the owner of the /c13scratch/rudrab: ll /...
0
votes
3answers
484 views

MV exclude folder not working

I'm trying to copy all of the files/directories inside a folder but would like to exclude one folder as I want all the other file to be inside that folder. To better demonstrate below is the folder ...
4
votes
1answer
339 views

Linux Redhat 7 : How to set a shell option globally / system-wide?

I'm having some troubled time trying to figure out how to turn on the xpg_echo option of the bash for every shell that will get run on my Linux RedHat system (7.4). I know I can have what I need (the ...
9
votes
3answers
816 views

How can I prevent unsupported 'shopt' options from causing errors in my .bashrc?

I work in a relatively heterogeneous environment where I may be running different versions of Bash on different HPC nodes, VMs, or my personal workstation. Because I put my login scripts in a Git repo,...
1
vote
1answer
28 views

Excluding certain files from moving but move hidden ones too

In my deployment script I have such as code to exclude certain files. shopt -s extglob mv !(deploy.sh|file1|file2) ~/$public It works almost well but ignores hidden files so they are not moved. How ...
3
votes
2answers
244 views

globstar: `**string*` not descending into subdirs `**/*string*` does

Given is a set of files in (sub)directories matching a string like in e.g.: find -name 'string' | sort ./1/2/3/4/string ./1/2/3/string ./1/2/string ./1/string ./string Why does using globstar to ...
1
vote
1answer
40 views

Change shopt output

Is there a way to change the output when shopt is invoked to something more verbose like a different color or a custom text? For example: ~ >> shopt -s cdspell ~ >> cd Projectss Projects ...
7
votes
1answer
348 views

Is there a shopt glob setting or setting combo that behaves like tcsh?

I'm transitioning from being a long time tcsh user to a new bash user (it's way overdue). I wrote a lot of foreach loops in tcsh on the fly on a regular basis, so I learned the syntax for bash's for ...
0
votes
1answer
421 views

shopt -s extdebug in .bashrc not working in script files

I am writing a a bash script echoo.sh with the intention of echoing commands before they are executed. I source the script inside .bashrc. But it does not affect other bash scripts that I run. Below ...
6
votes
5answers
2k views

Check for bash options

I have a function and would like to use the pipefail option inside. But I don't want to simply set -o pipefail, because I fear that another part of the script may not expect pipefail to be set. Of ...
8
votes
5answers
970 views

When is a multiline history entry (aka lithist) in bash possible?

In the bash reference manual it states: lithist If enabled, and the cmdhist option is enabled, multi-line commands are saved to the history with embedded newlines rather than using semicolon ...
3
votes
1answer
360 views

Bash 'cd' with cdable_vars: how to suppress CWD echo?

I have used the Bash shopt cdable_vars option for years. When I cd to a destination that requires cdable_vars to resolve, the shell echoes my CWD before returning me to the prompt. When I cd to a ...
-1
votes
1answer
691 views

Why No manual entry for shopt? [duplicate]

man-db is already the newest version. shopt can run,but no man shopt info.
0
votes
3answers
532 views

Is there a “ls” replacement that can handle wildcards?

I just learned that ls cannot handle wildcards (ls '*' does not work) and therefore the shell does it before ls is invoked. So the behaviour of ls may be considered as logically for people working 20 ...
6
votes
2answers
1k views

Why does history not overwrite but append when histappend is set to off in Bash?

Several days ago, I had one Terminal tab doing ssh, and the other doing a lot of work locally. And then I restarted the machine (on a Mac with Mavericks). When I ran Terminal again, I found that all ...
29
votes
5answers
12k views

How can I list bash'es options for the current shell?

The bash intepreter itself has options, i.e. Lines 22-23 of bash's man page: OPTIONS All of the single-character shell options documented in the description of the set builtin command can be ...
4
votes
1answer
886 views

Scope of shopt options in cron script

I have a bash script that is run nightly in a cron job. It needs to do case insensitive file matching, so the script calls shopt -s nocaseglob I want to make sure this does not affect other cron ...
1
vote
0answers
52 views

How to combine Bash's read with HERE-document when shopt -os errexit is in place? [duplicate]

I am trying to make use of the solution presented in one of the answers of https://stackoverflow.com/questions/1167746/how-to-assign-a-heredoc-value-to-a-variable-in-bash In Bash version 4.2.47(1)-...
0
votes
1answer
458 views

Is there a command which displays options like `errexit` and `braceexpand` other than `help set`?

If you type help set, then - among other things - a list of shell options is displayed. But these options are not the same as those displayed with shopt. And different also from those displayed with ...
6
votes
3answers
783 views

How can I make my .bashrc call to shopt -s autocd depend on the bash version?

In Ubuntu I like having shopt -s autocd in my .bashrc file for automatic CD'ing with typing 'cd', i.e. just type the directory name (and probably use tab completion too) and press return and be cd'd ...
7
votes
2answers
5k views

How do you get descriptions of the available `shopt` options?

What is the canonical way for accessing the local documentation on any available Shell Options builtin with shopt? I'm using Ubuntu 12.04 and can run help shopt to get a description of what shopt ...
4
votes
1answer
2k views

bash not setting autocd

I try to set autocd option in bash so I don't have to type cd src and can just type src. However shopt -s autocd gives me: -bash: shopt: autocd: invalid shell option name (Ubuntu 8.04 hardy)
6
votes
2answers
1k views

Function caller positional parameters

I need to read and write the positional parameters $@ of a function's caller. The Bash man page says that: A shell function is an object that is called like a simple command and executes a ...
8
votes
1answer
2k views

What are the scope restrictions for setting shopt extglob. and other options?

My non-interactive bash shell has extglob off. I would like to turn it on in the statement immediately before a command, but I have noticed that when shopt -s extglob is within an if .. then .. else ...
76
votes
7answers
21k views

Set and Shopt - Why Two?

set and shopt are both shell builtins that control various options. I often forget which options are set by which command, and which option sets/unsets (set -o/+o, shopt -s/-u). Why are there two ...