linux - Do command substitutions not affect the state of the shell? -


this example stores current directory of script in mydir echos same directory before , after variable assignment(even though cd called) leading me think command substitutions don't affect state of shell. true command substitutions?

#! /bin/bash  echo "$pwd" mydir="$( cd "$( dirname "$0" )" && pwd )" echo "$pwd" 

indeed; command substitutions executed in subshell. cannot change environment of parent process.


Comments

Popular posts from this blog

php - Dynamic url re-writing using htaccess -

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -