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
Post a Comment