In short: You need to do what the error message tells you to do.
Longer version: There are two things called parset
. The first is a shell script that tells you how to enable the function version. That's the entire purpose of this script, to provide setup instructions for people trying to run parset without having first loaded the function definition (and when the function is defined, it takes precedence over the script, so running parset
runs the function instead of the script)
The second is a shell function that actually does the work (why does it have to be a function? Because a function running in a shell can modify its own environment while a child process can not modify the environment of its parent. If it were a script, it would be a child process of the parent shell and unable to do its job). That function needs to be defined in the shell that uses it.
To define the function, you need to source env_parallel.$SHELL
in your script before you use the functions it defines. That's probably being done in your shell login startup scripts (e.g. ~/.bash_profile
) but not in your non-login startup scripts (e.g. ~/.bashrc
), which is why it works from your terminal but not from a script.
In other words, if your script is run with bash as the interpreter and the env_parallel.*
scripts are in /usr/bin/
, add the following somewhere near the start of your script:
. /usr/bin/env_parallel.bash
IMPORTANT: source the appropriate env_parallel.SHELL for the interpreter you're running your script with. e.g. on my debian system, parallel
provides the following:
$ ls -l /usr/bin/env_parallel*
-rwxr-xr-x 1 root root 4749 Aug 29 2021 /usr/bin/env_parallel
-rwxr-xr-x 1 root root 14565 Aug 29 2021 /usr/bin/env_parallel.ash
-rwxr-xr-x 1 root root 13565 Aug 29 2021 /usr/bin/env_parallel.bash
-rwxr-xr-x 1 root root 5377 Aug 29 2021 /usr/bin/env_parallel.csh
-rwxr-xr-x 1 root root 14554 Aug 29 2021 /usr/bin/env_parallel.dash
-rwxr-xr-x 1 root root 6643 Aug 29 2021 /usr/bin/env_parallel.fish
-rwxr-xr-x 1 root root 12595 Aug 29 2021 /usr/bin/env_parallel.ksh
-rwxr-xr-x 1 root root 12626 Aug 29 2021 /usr/bin/env_parallel.mksh
-rwxr-xr-x 1 root root 14754 Aug 29 2021 /usr/bin/env_parallel.sh
-rwxr-xr-x 1 root root 5380 Aug 29 2021 /usr/bin/env_parallel.tcsh
-rwxr-xr-x 1 root root 12604 Aug 29 2021 /usr/bin/env_parallel.zsh
Alternatively, add it to your non-login shell startup script (e.g. ~/.bashrc
) so that the parset
function is available to scripts run by non-login shells.
See man parset
for details.