summaryrefslogtreecommitdiffstats
path: root/noise
diff options
context:
space:
mode:
authortv <tv@also>2010-04-26 15:19:51 +0200
committertv <tv@also>2010-04-26 15:19:51 +0200
commit50aa02ccf1de40bc5f518d212a89c587c2b7d859 (patch)
tree87cebf2bf3a82d526e9f3bd3b3a2d3a965d57706 /noise
Rewrite of SHACK UTTERANCE 0.9 beta 1
Diffstat (limited to 'noise')
-rwxr-xr-xnoise102
1 files changed, 102 insertions, 0 deletions
diff --git a/noise b/noise
new file mode 100755
index 00000000..481f2c09
--- /dev/null
+++ b/noise
@@ -0,0 +1,102 @@
+#! /bin/sh
+
+noise_set() { # set a variable
+ if test "x$1" = x ; then
+ env | sed -rn '
+ s/^noise_([[:alnum:]_]+)=(.*)$/\1 = \2/p
+ ' | sort
+ elif test "x$2" = x ; then
+ eval "echo \"$1 is \$noise_$1\""
+ else
+ if echo "$1" | grep -q '[^[:alnum:]_]' ; then
+ fail invalid variable name "$1"
+ return 23
+ fi
+ eval "old=\"\$noise_$1\""
+ if test "x$old" = "x$2" ; then
+ eval "echo \"$1 is already $2\""
+ elif test -z "$old" ; then
+ eval "export noise_$1='$2' ; echo \
+\"$1 set to $2\""
+ else
+ eval "export noise_$1='$2' ; echo \
+\"$1 changed from $old to $2\""
+ fi
+ fi
+}
+
+noise_quit() { # exit
+ echo "Good bye!"
+ exit
+}
+
+fail() {
+ echo "FAIL: $*"
+ return 23
+}
+
+linefeed="/tmp/noise-client-$$"
+trap "rm -f $linefeed" 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
+ #echo "command: $command; args: $args"
+ ## modcall
+ for dir in `echo "$NOISE_PATH" | tr : \ ` ; do
+ module="$dir/$command"
+ if test -x "$module" ; then
+ shift
+ NOISE="$0" NOISE_linefeed="$linefeed" "$module" $args
+ continue 2
+ fi
+ done
+ ## funcall
+ if type noise_$command &>/dev/null ; then
+ noise_$command $args
+ continue
+ fi
+ ##
+ fail unknown command "$command"
+done <$linefeed &
+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
+$REPLY
+EOF
+done
+#### end of file.
+
+
+
+
+exit
+modcall() {
+ for dir in `echo "$NOISE_PATH" | tr : \ ` ; do
+ module="$dir/$1"
+ if test -x "$module" ; then
+ shift
+ "$module" "$@"
+ : && return
+ fi
+ done
+ return 23
+}
+
+funcall() {
+ if type noise_"$1" &>/dev/null ; then
+ noise_"$@"
+ : && return
+ fi
+ return 23
+}