unix - Bad use of parentheses -


i've been stuck on hours:

cd /dir1 (cd $home); pwd; 

why pwd still /dir1 , didn't go home directory?

parentheses start subshell: shell calls fork, , commands inside parentheses executed in subprocess. parent process waits subprocess exit resumes execution. what's happening is:

  • execution of cd /dir1: shell performs chdir("/dir1").
  • execution of parentheses: shell calls fork, parent process waits child exit.
  • execution of cd $home: subshell performs chdir("/home/jurgen").
  • the subshell has run out of commands, exits.
  • the subshell has exited, wait call in parent returns.
  • execution of pwd: shell prints current directory, /dir1.

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -