# !/bin/sh
# lkst_test_run

usage () {
cat <<EOF

lkst_test_run: run specified COMMAND with ARGS, while
  lkst uses new buffer that is just for the COMMAND.
USAGE: lkst_test_run BUFFER_SIZE COMMAND [ARGS ... ]

EOF
}

AWK=awk

if [ -z "$2" ]
then
	usage
	exit 1
fi

	# Stop buffer auto shifting (change maskset).
lkstm read -d | $AWK '{if (/0xf11/) {print " " $1 "		 0x0ff"} else {print}}'  | lkstm write -f - -n noshift -S

	# create new buffers
lkstbuf create -s $1
	# create dummy buffers
lkstbuf create -s 8192

	# shift arguments
shift

	# shift to the new buffer
lkstbuf shift

	# Excecute commands.
$*

	# shift to the dummy buffer to avoid overwritten.
lkstbuf shift

	# read all buffers
lkstbuf read

#END


