我有一个脚本文件
文件名: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 found
和2) export:4: invalid option(s)
[当我尝试使用bash
时有效
$ sh test_sem_zsh.sh
Happy day
因此如何使此脚本也与zsh
一起使用
不确定您要做什么,但这可以帮助您定义可以在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"