On 8/7/11 6:00 PM, Curtis Doty wrote: > I've recently refactored my PROMPT_COMMAND function to avoid superfluous > fork()s. In the body of the function, what was once this line: > > local jobcount=$(jobs |wc -l) > > is now this: > > local job jobcount=0 > while read job > do ((jobcount++)) > done < <(jobs)
As you suspect, the problem is with this part of the function. It doesn't really have anything to do with PROMPT_COMMAND, though. You must be exporting the function so your PROMPT_COMMAND will work in interactive subshells, and the problem is there. > > This works fine on bash 4. However, when attempting to use this on an older > bash 3.00.15(1) host, an error occurs; but only on 2nd or additional > subshells--not the first login shell!?! I.e. everything works fine, until I > run bash from bash. > > bash: foo: line 39: syntax error near unexpected token `(' > bash: foo: line 39: ` done <<(jobs);' > bash: error importing function definition for `foo' > > Am I missing a finer point of redirection from a substituted process? Or is > something different in bash 3 that I need to work around here? One of the bugs fixed between bash-3.1 and bash-3.2 concerned formatting problems with redirections and process substitution -- the construct you used. That code is used to decompose functions to pass them through the environment, and the incorrectly-formed function has a syntax error that prevents it being imported by the subshell. 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/