From 3ee6fac509018191edb5c424fbd3adb4b1b25100 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 26 Apr 2010 19:41:59 +0200 Subject: noise: factorized out the reader --- noise | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) (limited to 'noise') diff --git a/noise b/noise index fe67052c..048726f2 100755 --- a/noise +++ b/noise @@ -40,13 +40,28 @@ cleanup() { kill $jobs } + +qname="`readlink -f "$0"`" +dirname="`dirname "$qname"`" +if test -d "$dirname/modules" ; then + export NOISE_PATH="${NOISE_PATH+$NOISE_PATH:}$dirname/modules" +fi linefeed="/tmp/noise-client-$$" trap cleanup EXIT mkfifo $linefeed -while eval `{ read && echo $REPLY ; } | tr -d \' | sed -rn " - s:^/([a-z]+)([[:space:]]+(.*))?$:command='\1'; args='\3';:p;t - s:.*:command='$noise_default_command'; args='&';:p;t - "` ; do +## +## +## +readline() { + { read && echo $REPLY ; } | sed -rn " + s/['\"]//g + s:^/([a-z]+)([[:space:]]+(.*))?$:command=\1; args='\3';:p;t + s@^([[:alnum:]_/+-]+):[[:space:]]*(.*)@command=lang; args='\1 \2';@p;t + s@^\![[:space:]]*(.*)@command=play; args='\1';@p;t + s:.*:command='$noise_default_command'; args='&';:p;t + " +} +while eval "`readline`" ; do #echo "command: $command; args: $args" ## modcall for dir in `echo "$NOISE_PATH" | tr : \ ` ; do @@ -66,18 +81,24 @@ while eval `{ read && echo $REPLY ; } | tr -d \' | sed -rn " fail unknown command "$command" done <$linefeed & jobs="${jobs+$jobs }`jobs -p`" +## +## +## cat<>$linefeed echo /set default_command espeak - while read ; do - case $REPLY in - (/quit) echo /quit ; exit ;; - (*) tr \; \\n | grep . ;; - esac<