#!/bin/bash
## this script is not intended for interactive use
## write the pid of this process
#set -x

printf "$$" 1> $HOME/.bashish/tmp/${TTY##*/}/pid
## init bashish
. $BASHISHDIR/main/terminal/init

## main loop
## wait for input from FIFO, execute input, loop
while true
do

	until test x$BTAPP != x
	do
	unset BTAPP BASHISH_ARGV ARGV EVAL

	## test if fifo is avaliable
	test -p $HOME/.bashish/tmp/${TTY##*/}/subproc||exit 1
	read EVAL <"$HOME/.bashish/tmp/${TTY##*/}/subproc"
	eval $EVAL
	_bashish_brefresh
	sleep 1
	done

## until
	until test "x${BASHISH_ARGV[0]}" = x
	do
	unset BTAPP BASHISH_ARGV[*] EVAL
	## test if fifo is avaliable
	test -p $HOME/.bashish/tmp/${TTY##*/}/subproc||exit 1
	read EVAL <"$HOME/.bashish/tmp/${TTY##*/}/subproc"
	eval $EVAL
	done

	_bashish_brefresh
	unset BTAPP BASHISH_ARGV[*] BASHISH_ARGC EVAL
	sleep 1
done
