Merge branch 'obsd-master'
[tmux.git] / regress / new-session-environment.sh
blobd53f204eb4b40455a4063ca0a141e48b950b5287
1 #!/bin/sh
3 # new session environment
5 PATH=/bin:/usr/bin
6 TERM=screen
8 [ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux)
9 TMUX="$TEST_TMUX -Ltest"
10 $TMUX kill-server 2>/dev/null
12 TMP=$(mktemp)
13 OUT=$(mktemp)
14 SCRIPT=$(mktemp)
15 trap "rm -f $TMP $OUT $SCRIPT" 0 1 15
17 cat <<EOF >$SCRIPT
19 echo TERM=\$TERM
20 echo PWD=\$(pwd)
21 echo PATH=\$PATH
22 echo SHELL=\$SHELL
23 echo TEST=\$TEST
24 ) >$OUT
25 EOF
27 cat <<EOF >$TMP
28 new -- /bin/sh $SCRIPT
29 EOF
31 (cd /; env -i TERM=ansi TEST=test1 PATH=1 SHELL=/bin/sh \
32 $TMUX -f$TMP start) || exit 1
33 sleep 1
34 (cat <<EOF|cmp -s - $OUT) || exit 1
35 TERM=screen
36 PWD=/
37 PATH=1
38 SHELL=/bin/sh
39 TEST=test1
40 EOF
42 (cd /; env -i TERM=ansi TEST=test2 PATH=2 SHELL=/bin/sh \
43 $TMUX -f$TMP new -d -- /bin/sh $SCRIPT) || exit 1
44 sleep 1
45 (cat <<EOF|cmp -s - $OUT) || exit 1
46 TERM=screen
47 PWD=/
48 PATH=2
49 SHELL=/bin/sh
50 TEST=test2
51 EOF
53 (cd /; env -i TERM=ansi TEST=test3 PATH=3 SHELL=/bin/sh \
54 $TMUX -f/dev/null new -d source $TMP) || exit 1
55 sleep 1
56 (cat <<EOF|cmp -s - $OUT) || exit 1
57 TERM=screen
58 PWD=/
59 PATH=2
60 SHELL=/bin/sh
61 TEST=test2
62 EOF
64 $TMUX kill-server 2>/dev/null
66 exit 0