As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [shopt]

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

Filter by
Sorted by
Tagged with
3 votes
1 answer
497 views

Are there any caveats in using shopt -s autocd?

I have recently discovered the feature shopt -s autocd: autocd If set, a command name that is the name of a directory is executed as if it were the ...
mgarort's user avatar
  • 425
1 vote
0 answers
100 views

Usage of gnu_errfmt option in bash

I readed GNU/Bash document but i can't understand or find any realworld usage example. gnu_errfmt If set, shell error messages are written in the standard GNU error message format. When i try: └─$ ...
testter's user avatar
  • 1,260
-1 votes
1 answer
447 views

What does shopt histreedit do?

shopt histreedit is supposed to allow the user to re-edit a failed history substitution. How can a history substitution fail? How is histreedit different from histverify?
EmmaV's user avatar
  • 3,903
7 votes
1 answer
348 views

Should the option "--rcfile /dev/null" have the same effect as "--norc" when invoking bash?

To avoid the XY problem scenario, I'll explain why I'm asking this question. I remember I had shopt -s extglob set in my ~/.bashrc file, because things like @(pattern-list) do work. However, I've just ...
Enlico's user avatar
  • 1,297
-2 votes
2 answers
87 views

mv cdable_vars - where has my .bashrc gone? [closed]

I thought it would be clever to have an alias to my dotfiles repo, where I keep my dotfiles such as .bashrc. Following a recommendation, I added this to my .bashrc: shopt -s cdable_vars export ...
Alex's user avatar
  • 105
1 vote
0 answers
195 views

is it enough to set "shopt -s nocaseglob" once / script?

Is it enough to set shopt -s nocaseglob once in a bash-script, or do I need to set it before every function in the script. Do I need to turn it on again after the script is completed or is this only a ...
JoBe's user avatar
  • 377
1 vote
1 answer
293 views

bash overrides the history even with histappend set to on

I'm trying to write the bash history to a file (...| 1 |...), then change one character (...| 2 |...) in HISTTIMEFORMAT environment variable run couple commands and being able to see commands from the ...
Vor's user avatar
  • 113
2 votes
1 answer
645 views

Aliases don't work in interactive zsh

I have a curious problem where my aliases are listed when I type alias, but they are not executable. Here, I try to alias d to date: % which alias alias: shell built-in command % alias d=/usr/bin/...
Tom Hale's user avatar
  • 28.1k
2 votes
1 answer
955 views

Extended globbing inside script - what am I doing wrong?

so I'm trying to select a range of files using an interactive script. The end goal is to use the read command but for demonstration here I assigned the glob variable manually #!/bin/bash shopt -s ...
Eike's user avatar
  • 29
1 vote
1 answer
89 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 ...
Axel Krypton's user avatar
0 votes
1 answer
377 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, ...
RG7's user avatar
  • 115
1 vote
1 answer
516 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 ...
mgutt's user avatar
  • 347
10 votes
1 answer
673 views

Setting bash options in a compound command

I have found that setting the extglob shell option only within a compound compound results in failure of subsequent extended globs. Are shell options required to be set outside of compound commands? I ...
user001's user avatar
  • 3,568
1 vote
0 answers
123 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; (...
sdbbs's user avatar
  • 450
1 vote
1 answer
375 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 /...
BaRud's user avatar
  • 1,589
0 votes
3 answers
2k 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 ...
MadzQuestioning's user avatar
5 votes
1 answer
921 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 ...
R. Du's user avatar
  • 161
10 votes
3 answers
2k 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,...
TheDudeAbides's user avatar
1 vote
1 answer
34 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 ...
trzczy's user avatar
  • 630
3 votes
2 answers
820 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 ...
FelixJN's user avatar
  • 11.9k
1 vote
1 answer
60 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 ...
vise's user avatar
  • 133
8 votes
1 answer
768 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 ...
hepcat72's user avatar
  • 195
0 votes
1 answer
673 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 ...
Sam Thomas's user avatar
6 votes
5 answers
4k 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 ...
red_trumpet's user avatar
15 votes
5 answers
2k 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 ...
humanityANDpeace's user avatar
3 votes
1 answer
859 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 ...
Chap's user avatar
  • 359
0 votes
1 answer
1k views

Why No manual entry for shopt? [duplicate]

man-db is already the newest version. shopt can run,but no man shopt info.
showkey's user avatar
  • 345
0 votes
3 answers
848 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 ...
user avatar
10 votes
2 answers
3k 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 ...
nonopolarity's user avatar
  • 2,899
50 votes
5 answers
24k views

How can I list Bash's options for the current shell?

The Bash interpreter itself has options. For example, those mentioned on lines 22-23 of Bash's man page: OPTIONS All of the single-character shell options documented in the description of the set ...
the_velour_fog's user avatar
6 votes
1 answer
1k 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 ...
Jeff's user avatar
  • 163
1 vote
0 answers
88 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)-...
Tim Friske's user avatar
  • 2,180
0 votes
1 answer
711 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 ...
AmadeusDrZaius's user avatar
6 votes
3 answers
1k 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 ...
Michael Durrant's user avatar
9 votes
2 answers
13k 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 ...
bnjmn's user avatar
  • 193
4 votes
1 answer
3k 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)
user53689's user avatar
6 votes
2 answers
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 ...
Pedro Lacerda's user avatar
11 votes
1 answer
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 ...
Peter.O's user avatar
  • 32.2k
106 votes
7 answers
27k 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 ...
Kevin's user avatar
  • 39.7k