summaryrefslogtreecommitdiffstats
path: root/noise
diff options
context:
space:
mode:
authorroot <root@shack.fritz.box>2010-04-26 19:41:59 +0200
committerroot <root@shack.fritz.box>2010-04-26 19:41:59 +0200
commit3ee6fac509018191edb5c424fbd3adb4b1b25100 (patch)
tree57e1c044ef723c1be2baf0205075d78d5675648b /noise
parente178d987dd59f25e6ec0b85fa1fbc22308b2d213 (diff)
noise: factorized out the reader
Diffstat (limited to 'noise')
-rwxr-xr-xnoise39
1 files changed, 30 insertions, 9 deletions
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<<EOF
welcome to SHACK UTTERANCE version 0.9 beta 2
get help with /help
TIP: benutze rlwrap für eine elitäre Kommandozeile.
EOF
+##
+##
+##
exec >>$linefeed
echo /set default_command espeak
- while read ; do
- case $REPLY in
- (/quit) echo /quit ; exit ;;
- (*) tr \; \\n | grep . ;;
- esac<<EOF
+while read ; do
+ case $REPLY in
+ (/quit) echo /quit ; exit ;;
+ (*) tr \; \\n | grep . ;;
+ esac<<EOF
$REPLY
EOF
done