Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [shopt]

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

0
votes
3answers
38 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 ...
3
votes
1answer
65 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 ...
0
votes
0answers
18 views

How can I ensure some shell or bash option is enabled or disabled and later on restore it if I have changed it? [duplicate]

Sometimes I want to do something which requires some shell or bash option enabled or disabled. For example, https://unix.stackexchange.com/a/108520/674 So I could first change the shell or bash ...
0
votes
0answers
19 views

Do display managers like sddm actually set the login_shell option?

I have a script which distinguishes if it is sourced from within a login shell or not. But it happens not to do its job as the login was done through display manager sddm. #!/bin/bash # /etc/bash....
7
votes
3answers
618 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. I like the default behavior of Bash <= 4....
1
vote
1answer
25 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
59 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
0answers
23 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 ...
6
votes
1answer
172 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
221 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 ...
5
votes
5answers
941 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 ...
6
votes
3answers
550 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 ...
0
votes
0answers
24 views

Bash pattern prefix removal script vs. interactive [duplicate]

I used to test my Bash commands interactively on the CLI and then copy them over onto a SH script. This worked fine until today. Run the following on your command line a=008; echo ${a##*(0)} and ...
3
votes
1answer
217 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
439 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
4answers
425 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
918 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 ...
23
votes
5answers
9k 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 ...
3
votes
1answer
690 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
39 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
406 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
643 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
4k 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 ...
3
votes
1answer
1k 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)
5
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 ...
5
votes
1answer
1k 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 ...
65
votes
7answers
17k 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 occasionally which option sets/unsets (set +o/-o, shopt -s/-u). Why are ...