FAQ Database Discussion Community


Bash subshell for setting SHELLOPTS in a script

bash,cygwin,subshell
This question is not cygwin specific. However, in the cygwin mail archive https://cygwin.com/ml/cygwin-announce/2010-08/msg00015.html are various instructions for setting the cygwin specific igncr shellopt variable and one of them is the instruction: 4a. For a single affected script, add this line just after the she-bang: ~ (set -o igncr) 2>/dev/null &&...

shell variable not keeping value [duplicate]

bash,shell,unix,pipeline,subshell
This question already has an answer here: Bash while read resetting variable values - using the read builtin in a pipeline 3 answers I have 3 lines in file /root/backuplist.txt. The first echo prints perfectly, but the last one prints an empty line; I'm not sure why. Somehow, the...

Assign and use of a variable in the same subshell

bash,scope,subshell
I was doing something very simple like: v=5 echo "$v" and expected it to print 5. However, it does not. The value that was just set is not available for the next command. I recently learnt that "In most shells, each command of a pipeline is executed in a separate...