本文介绍了zsh 和并行:如何使用函数.它说找不到命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个脚本文件
文件名: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)
It says two error's 1) main command not found
and 2) export:4: invalid option(s)
当我尝试使用 bash
时它可以工作
Where as when i try with bash
it works
$ sh test_sem_zsh.sh
Happy day
那么如何让这个脚本与 zsh
一起工作
So how to get this script working with zsh
also
推荐答案
sem
只是 parallel --semaphore
的简写.
你可以使用env_parallel
:
#!/usr/bin/zsh
# activate env_parallel (if not already done)
. =env_parallel.zsh
env_parallel --semaphore --id testing --fg main
或者如果您的环境太大:
Or if your environment is too big:
#!/usr/bin/zsh
# activate env_parallel (if not already done)
. =env_parallel.zsh
env_parallel --session
main() {
echo "Happy day"
}
env_parallel --semaphore --id testing --fg main
env_parallel --end-session
这篇关于zsh 和并行:如何使用函数.它说找不到命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!