#!/bin/sh                                                                      
# This is an example of how to drive the Quantum system
# through from userspace through the text-based /proc
# interface. It can be used as a very simple-minded console
# (C) GlobespanVirata 2002
#

prfix=""
prmpt="qsh>"

# If invoked with arguments, pass them to quantum and quit
if [ "$1" != "" ]; then
        echo -e  "$*\000" > /proc/quantum/console
        exit 0;
fi 
 
# Otherwise be an interactive console
echo Quantum mini-console v1.0                           
echo This is example code only.                                      
echo Hit Ctrl-d when done.                                                         
echo -n $prmpt                                                                   
while read line; do                                                              
  case $line in
    home)
        prfix="";
        prmpt="qsh>";;
    :*)
        prfix=`echo $line | sed 's/^://'`;
        prmpt=${prfix}\>;;
    \#*)
	echo ;;
    !*)
	cmnd=`echo $line | sed 's/^!//'`;
	sh -c "$cmnd";;
     *)
        echo -e  "${prfix} ${line}\000" > /proc/quantum/console;;                            
  esac
  echo -n $prmpt;                   
done                                                                            
