Thank you, Hans. I'm aware of that workaround, but I thought you'd want to know that env_parallel is not fully robust and fails in obscure ways. Is env_parallel deprecated? The man page doesn't seem to say so.
Note that the workaround only works in Bash, because other shells do not support exporting functions. Best, Michael > On Apr 15, 2017, at 4:36 AM, Hans Schou <[email protected]> wrote: > > Try add "export -f doIt" in your chain. > > This is my test command: > > doIt() { echo "$$: [$*]"; } ; export -f doIt ; { echo hi; echo there; echo > you; echo too; } | parallel -n 1 -j 12 doIt {} > > 27659: [hi] > 27660: [there] > > > 27661: [you] > > > 27662: [too] > > > > Read more in the man page chapter "EXAMPLE: Calling Bash functions" > > 2017-04-14 20:53 GMT+02:00 Michael Klement <[email protected] > <mailto:[email protected]>>: > * The version number: 20170322 > * The bugid: open3-GLOB(0x7fec07207648) > > Note: The cause are the specific functions defined in my Bash environment. > If I manually modify function env_parallel() in > /usr/local/bin/env_parallel.bash, to only include the one function of > interest - local _list_function_BODIES="typeset -f doIt" - , everything > works fine. > > * The command line being run: > > . /usr/local/bin/env_parallel.bash; doIt() { echo "$$: [$*]"; }; { echo hi; > echo there; echo you; echo too; } | env_parallel -n 1 -j 12 doIt {} > > In my macOS 10.12.4 the command breaks with both the stock Bash version > (3.2.57) as well as a Homebrew-installed recent version bash (4.4.5) > v3.2.57: only stderr output: > -bash: /usr/bin/which: Argument list too long > -bash: -n: command not found > v4.4.5: only stderr output: > The auto-detected bug condition with environment information included, > including all function bodies (see attached file): > > > As you can see, with the stock macOS Bash even the bug-detection mechanism > failed - the `which parallel` command in function env_parallel() malfunctions > and parallel never even gets to execute. > > Regards, > > Michael > > > >
