diff options
author | tv <tv@also> | 2010-05-07 04:52:10 +0200 |
---|---|---|
committer | tv <tv@also> | 2010-05-07 04:52:10 +0200 |
commit | ee937603bb8ad9b18d03113bee4759811748d337 (patch) | |
tree | ea4cff25143181f66053d2e4367deea656d62388 /noise | |
parent | 75d12a3ba0c0a2bc9adaeb6660757d8dfdff6f1e (diff) | |
parent | e164088a38e067b4456cf131a260e3cdd90d0fb3 (diff) |
Merge ssh://shack/~/noise
Diffstat (limited to 'noise')
-rwxr-xr-x | noise | 36 |
1 files changed, 26 insertions, 10 deletions
@@ -29,6 +29,12 @@ noise_set() { # set a variable eval "export noise_$1='$2' ; $echo \ \"[35;4m$1[0;35m changed from $old to [0;32m$2[m\"" fi + ## write variable to $env + if grep -q "^$1=" "$env" ; then + sed -ri "s'^($1)=(.*)\$'\1=\'$2\''" $env + else + echo "$1='$2'" >>$env + fi ;; esac } @@ -44,27 +50,35 @@ fail() { } cleanup() { - rm -f $linefeed kill $jobs + rm -f $linefeed $env + rmdir /tmp/noise/$$ 2>/dev/null + rmdir /tmp/noise 2>/dev/null } qname="`readlink -f "$0"`" dirname="`dirname "$qname"`" +export HOME='/home/shack' if test -d "$dirname/modules" ; then export NOISE_PATH="${NOISE_PATH+$NOISE_PATH:}$dirname/modules" export NOISE_PATH="${NOISE_PATH+$NOISE_PATH:}$HOME/noise/modules" fi -linefeed="/tmp/noise-client-$$" +mkdir -vp /tmp/noise/$$ +linefeed="/tmp/noise/$$/linefeed" +env="/tmp/noise/$$/environment" trap cleanup EXIT mkfifo $linefeed +touch $env ## ## ## readline() { { read && echo "$REPLY" ; } | sed -rn " s/[']//g - s:^/([a-z]+)([[:space:]]+(.*))?$:command=\1; args='\3';:p;t + s/~%/\n/g + s/([^\\])([#<>])/\1\\\\\2/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 @@ -73,19 +87,13 @@ readline() { ## ## ## -export noise_prompt="[30mREADY.[m -" -export noise_default_command=espeak -## -## -## while echo -n "$noise_prompt" && eval "`readline`" ; do ## modcall for dir in `echo "$NOISE_PATH" | tr : \ ` ; do module="$dir/$command" if test -x "$module" ; then shift - eval 'NOISE="$0" NOISE_linefeed="$linefeed" "$module"' "$args" + eval 'NOISE="$0" NOISE_pid="$$" NOISE_linefeed="$linefeed" "$module"' "$args" continue 2 fi done @@ -110,6 +118,14 @@ EOF ## ## exec >>$linefeed +## +## +## +echo '/set prompt "[30mREADY.[m~%"' +echo '/set default_command espeak' +## +## +## while read ; do case $REPLY in (/quit) echo /quit ; exit ;; |