Eric Blake respondeu na lista de discussão do bash-bugs:
jobs
is an interesting builtin - the set of jobs in a parent shell is DIFFERENT than the set of jobs in a subshell. Bash normally creates a subshell in order to do a pipeline, and since there are no jobs in that subshell, the hidden execution of jobs has nothing to report.Bash has code to special-case
jobs |
when it can obviously tell that you are running the jobs builtin as the sole command of the left side of a pipe, to instead report about the jobs of the parent shell, but that special-case code cannot kick in if you hide the execution of jobs, whether by hiding it inside a function as you did, or by other means such as:eval jobs | grep vim