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
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
Views views:250
Sections title:apples
body:"apples oranges"
URL url:"*"
Favorites infavorites:mine
Status closed:yes
Types is:question
Exclude -[tag]
For more details on advanced search visit our help page
Results tagged with Search options user 95236

The shell is Unix's command-line interface. You can type commands in a shell interactively, or write scripts to automate tasks. Use this tag for questions applying to /bin/sh and most compatible shells (ash, bash, ksh, zsh, …). For shell scripts with errors, please check them in before posting here.

Shell variables always belong to the current shell. When you spawn a subshell, it is a different shell, and hence has its own set of variables. In your case, you are running the subshell using … (......), so bash arranges that the subshell initially gets a copy of all variables of the parent shell, but that's it already. In particular, changes in the variables are not copied back when the subshell …
answered May 16 '18 by user1934428
You want a variable inside your function which, once set, keeps their value. Since this can be done only with a global variable, you need to give it a different name, for instance: xtest(){ typeset …
answered Sep 24 '18 by user1934428
As RalfFriedl already explained, whether or not this can have some impact, depends what is actually executed inside the sourced script. Since you didn't tell us the content of that script, there is no …
answered Aug 31 '18 by user1934428
I would put the logic upside down: # Note that the variables 'master' and 'integration' are NOT defined yet if [ -f '.vcs.json' ]; then master="${`read_json -f .vcs.json -k git.master`:-master}" …
answered Sep 12 '18 by user1934428
It's just a consequence of the old saying that "one man's data is an other man's program". Computers are built based on the Von-Neumann-Architecture, and this means that there is nothing inherent in f …
answered Mar 9 '18 by user1934428
vote you are asking bash to run the content of this script as commands, i.e. to execute a program with the funny name X=5. Hence, the correct way to bring the definitions into your shell would … invoker. In short, if a shell needs variables to be set, and the settings are defined in a separate file, it needs a source command to import those. …
answered Sep 19 '18 by user1934428
What do you mean by opening a new prompt? There are several ways in that Zsh runs something automatically: On starting a new shell, several startup files are executed (depending on how the shell is … new shell with tracing enabled (-x) and analyze the output. This should show you, where the mv comes from. …
answered Aug 15 '17 by user1934428
grep (and egrep or its modern equivalent grep -E) is your friend: man grep See the -v option. Here: grep -Exv '[[:blank:]]*[0-9]+c[0-9]+[[:blank:]]*' file would filter out lines consisting of c …
answered May 4 '15 by user1934428