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

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -