The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 05-26-2006
MichLab MichLab is offline
Registered User
  
 

Join Date: May 2006
Posts: 4
Thumbs up

Thanks for the insights.

I do find the behaviour borderline nuts presuming different rules for coercing variables.

An arguably valid definition I can think of as an alternate is that "$$" is by definition the initial shell's PID as opposed to the current process's PID, independent of sub-shells much like PPID is the parent of the initial shell regardless of being in a sub-shell or not. This is consistent with a few ksh man pages I dug up though not obvious.

It also seems to be consistent with a few experiments I tried with "eval" with a composite string that results in "$$" which would preclude the initial parsing of the (....)& from coercing a manifest $$ and that also produced the same result.

That ksh treats a subshell differently from a forked instance of ksh is consistent with other aspects of behaviour (e.g. variables need not be exported to be seen by a sub-shell) but it sure messes up the notion of using inline code vs external scripts in any consistent manner.

I will derive an alternative strategy (messing with ps -ef is not an option because my code needs to run under Solaris and Windows/MKS wherein ps differs due to the information about process parameters maintained by Windows).

Thanks again.
Michel