使用tmux的shell脚本在zsh上失败

时间:2014-02-19 17:02:36

标签: bash shell zsh tmux

我有以下脚本:

#!/usr/bin/env bash
# set -xv


tmux new-window -n 'foo' 'source "$HOME/.rvm/scripts/rvm"; sleep 123' \;

在一台机器上它完美运行,在第二台我遇到错误:

sh: 1: source: not found

来自shell的运行命令运行完美。 怎么了?机器有类似的点文件......

1 个答案:

答案 0 :(得分:4)

source不是POSIX命令。请改用.。失败的计算机可能使用dash作为系统shell,而不是bashtmuxbash脚本执行的事实并不意味着bash用于执行给new-window的命令。 tmux将使用系统shell /bin/sh,因此该命令不应依赖{POSO source的{​​{1}}同义词等非POSIX功能。