Sławosz
Sławosz

Reputation: 11687

Shell script using with tmux fails on zsh

I have following script:

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


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

On one machine it works perfectly, on the second I got an error:

sh: 1: source: not found

Ofcourse running command from shell works perfectly. What is wrong? Machines have similar dot files....

Upvotes: 1

Views: 593

Answers (1)

chepner
chepner

Reputation: 532053

source is not a POSIX command. Use . instead. The machine that fails is probably using dash as the system shell, not bash. The fact that tmux is executed from a bash script does not mean bash is used to execute the command given to new-window. tmux will use the system shell /bin/sh, so the command should not rely on non-POSIX features like the source synonym for ..

Upvotes: 3

Related Questions