Stupid bash scripting question

Michael ODonnell michael.odonnell at comcast.net
Thu Aug 25 09:45:00 EDT 2005


>> It seems that either will do the job, I'm just wondering (for the
>> purpose of my own "betterment" and improved knowledge of shell scripting
>> *grin*) about advantages of either approach.  The only one I've come
>> with so far is that Solution 2 requires a separate process to run.
>
>So does the first one; the `..` spawns another shell, and I believe 
>the eval spawns yet another shell. 


I haven't looked at the source codes but the following
experiment indicates that use of "eval" does not result
in the spawning of any additional processes:

   eval 'ps -eaf >/tmp/snapshot1'
   eval 'ps -eaf >/tmp/snapshot2'
   diff /tmp/snapshot1 /tmp/snapshot2

On my idle machine the only lines that differed were the
ones for the "ps" invocations.

 



More information about the gnhlug-discuss mailing list