zsh and parallel:如何使用函数。它说找不到命令

问题描述 投票:0回答:1

我有一个脚本文件

文件名:test_sem_zsh.sh

main() {
    echo "Happy day"
}
export -f main 
sem --id testing --fg main

我正在尝试使用zsh运行它

$ zsh test_sem_zsh.sh 
test_sem_zsh.sh:export:4: invalid option(s)
zsh:1: command not found: main

它说两个错误的1) main command not found2) export:4: invalid option(s)

[当我尝试使用bash时有效

$ sh test_sem_zsh.sh 
Happy day

因此如何使此脚本也与zsh一起使用

zsh gnu-parallel
1个回答
0
投票

不确定您要做什么,但这可以帮助您定义可以在sem下运行而无需bash的export的代码块:

#!/bin/zsh

# Create script in /tmp
script="/tmp/tmp-$$"
cat <<EOF > "$script"
echo "Happy day"
date
EOF

sem --id testing --fg /bin/zsh "$script"

rm "$script"
© www.soinside.com 2019 - 2024. All rights reserved.