On 4/11/13 12:15 PM, Lenga, Yair wrote: > Dan, Chet: Many thanks for the info about BASHPID. > > I've checked BASHPID on RH6, and it looks OK. Few comments related to making > the change visible, and POSIX compliance. > > + The 'set' command, does not print the BASHPID, this make it very hard to > find it (unless you read every line in the BASH info file !). > It will be very helpful to include BASHPID there (if set).
It does, but BASHPID is one of the special shell variables that springs into existence only when it's referenced. Run the following script; it should display two lines of output: sleep 1& echo $BASHPID set | grep ^BASHP > + The man page list BASH_VERSION, etc., but no indication of BASHPID. It's > probably a good idea to put a note next to '$!' about BASHPID. It's in there, and has been since bash-4.0. > + Could not find any change log on my system (probably a problem with RH). > Not sure if it's documented. That depends on your distribution. There is a summary changelog (CHANGES), a file listing new features (NEWS), and a detailed change log (CWRU/changelog) in the FSF bash distribution. > Also, I have a question about POSIX mode (and POSIX compliance). > The POSIX says '$!' is "most recent background command executed from the > current shell". > > So in : > > ( echo "$!") & > ( echo "$!") & > > According to POSIX, both calls should print "" (nothing). As the background > command does not come from the "current" shell. > > With BASH4, The first call will print "" (nothing), second call will print > the PID of the first call. The bash behavior is correct. The Posix requirement that (...) subshells create a `subshell environment', which is an exact copy of the parent shell's state with a couple of minor exceptions, trumps the text you quoted. http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_12 for the exact reference. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/