[英]How to source bash script in zsh
I have bash script which heavily uses bash features and does not run in zsh, dash, and sh.我有 bash 脚本,它大量使用 bash 功能并且不在 zsh、dash 和 sh 中运行。
My prefered shell is zsh.我最喜欢的 shell 是 zsh。 How can I source this bash script into zsh shell?
如何将此 bash 脚本导入 zsh shell?
I tried我试过了
function in() {
bash -c "'$@ ; exec zsh'"
}
but this gives me syntax errors like this但这给了我这样的语法错误
❯ in source t.bash
t.bash ; exec zsh': -c: line 1: unexpected EOF while looking for matching `''
t.bash ; exec zsh': -c: line 2: syntax error: unexpected end of file
I also tried to use xargs but then enviroment variables set by my bash script are not set in zsh我也尝试使用 xargs 但我的 bash 脚本设置的环境变量未在 zsh 中设置
function in () {
echo -c "'$@ ; exec zsh'" | xargs -t bash
}
but then enviroment variables set by my bash script are not set in zsh但是我的 bash 脚本设置的环境变量未在 zsh 中设置
copy pasting the command shown by xargs -t
does work复制粘贴
xargs -t
显示的命令确实有效
You said "copy pasting the command shown by xargs -t does work".您说“复制粘贴 xargs -t 显示的命令确实有效”。
So... if you changed所以...如果你改变了
function in () {
echo -c "'$@ ; exec zsh'" | xargs -t bash
}
to至
function in () {
echo -c "'$@ ; exec zsh'" | xargs -t bash >"${BATCH_FILE}"
chmod 754 "${BATCH_FILE}" ; "${BATCH_FILE}"
}
wouldn't that give you what you need?那不会给你你需要的吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.