export function from zsh to bash for use in gnu parallel
Based on that other guy's answer. You can write a function that export a zsh function that already defined to bash
function exportf (){
export $(echo $1)="`whence -f $1 | sed -e "s/$1 //" `"
}
Usage
function my_func(){
echo $1;
echo "hello";
}
exportf my_func
parallel "my_func {}" ::: 1 2
zsh
does not have a concept of exporting functions. export -f somefunc
will print the function definition, it will not export a function.
Instead, you can rely on the fact that bash functions are exported as regular variables starting with ()
:
export my_func='() { echo "$1"; }'
parallel --gnu "my_func {}" ::: 1 2