what is the meaning of FOOBAR=foobar followed by a shell command? -


i see in shell scripts variable assignment followed (without semicolon) command. meaning of that? not seem affect command, , not seem affect next command way normal assignment would:

>echo $foobar  >foobar=1 echo $foobar  >echo $foobar  > 

so, does do?

it sets environment variable value process.

here, step step, happens:

  • original command: foobar=1 echo $foobar
  • shell performs substitution: command foobar=1 echo
  • shell fork(2)s new process
  • environment variable created in new process: command echo (with $foobar equal 1)
  • new process exec(3)ed: \n output
  • new process exits , reaped shell

at no point parent process see assigned value of $foobar.


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 -