On Sun, 7 Aug 2011, Chet Ramey wrote:

On 8/7/11 6:00 PM, Curtis Doty wrote:
  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.
Aha, indeed I have this too:

  export -f foo

Removing it and the error goes away on successive subshells. :-)

I already export PROMPT_COMMAND=foo. Maybe I don't need to try and re-export the function every time also?
  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
Thanks Chet! I'll chalk this up as an old bug already fixed.

../C


Reply via email to