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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -