#!/bin/sh # a client lost while the configuration is loading is freed PATH=/bin:/usr/bin TERM=screen [ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux) TMPDIR=$(mktemp -d) || exit 1 TMUX="$TEST_TMUX -S$TMPDIR/tmux.sock" cleanup() { touch $TMPDIR/go $TMUX kill-server 2>/dev/null rm -rf "$TMPDIR" } trap cleanup 0 1 15 # Poll until a command succeeds. wait_for() { i=0 while ! "$@"; do [ $i -eq 100 ] && exit 1 i=$((i + 1)) sleep 0.1 done } # The run-shell holds the configuration until the go file exists. cat <$TMPDIR/conf new-session -d -s keep run-shell 'touch $TMPDIR/started; i=0; while [ ! -f $TMPDIR/go ] && [ \$i -lt 100 ]; do sleep 0.1; i=\$((i + 1)); done' EOF cd $TMPDIR || exit 1 $TMUX -v -f$TMPDIR/conf new-session -d -s first