summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorroot <root@shack.(none)>2010-05-07 02:01:02 +0200
committerroot <root@shack.(none)>2010-05-07 02:01:02 +0200
commit81344217c8a54e46d7cfc38466303d046e08e77f (patch)
tree005d11f950a777331f2222c06a0477543d4def2c
parentcb2ffed83727b2d20d9d0a71bf55adc96c168e62 (diff)
noise: write /set'ed variables to $env
Additionally: - Export $TCPREMOTIP to noise and modules. - Hardwired $HOME in noise. ;-) - Read ~% as Newline.
-rwxr-xr-xnoise26
-rwxr-xr-xnoise-as-shack2
2 files changed, 20 insertions, 8 deletions
diff --git a/noise b/noise
index 11976f68..0e60bbf2 100755
--- a/noise
+++ b/noise
@@ -29,6 +29,12 @@ noise_set() { # set a variable
eval "export noise_$1='$2' ; $echo \
\"$1 changed from $old to $2\""
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,26 +50,30 @@ fail() {
}
cleanup() {
- rm -f $linefeed
+ rm -f $linefeed $env
kill $jobs
}
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-$$"
+env="/tmp/noise-client-$$-env"
trap cleanup EXIT
mkfifo $linefeed
+touch $env
##
##
##
readline() {
{ read && echo "$REPLY" ; } | sed -rn "
s/[']//g
+ s/~%/\n/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
@@ -73,12 +83,6 @@ readline() {
##
##
##
-export noise_prompt="READY.
-"
-export noise_default_command=espeak
-##
-##
-##
while echo -n "$noise_prompt" && eval "`readline`" ; do
## modcall
for dir in `echo "$NOISE_PATH" | tr : \ ` ; do
@@ -110,6 +114,14 @@ EOF
##
##
exec >>$linefeed
+##
+##
+##
+echo '/set prompt "READY.~%"'
+echo '/set default_command espeak'
+##
+##
+##
while read ; do
case $REPLY in
(/quit) echo /quit ; exit ;;
diff --git a/noise-as-shack b/noise-as-shack
index c327bb81..10ae3c1c 100755
--- a/noise-as-shack
+++ b/noise-as-shack
@@ -1,4 +1,4 @@
#! /bin/sh
qname="`readlink -f "$0"`"
dirname="`dirname "$qname"`"
-exec su - shack -c "$dirname"/noise
+exec su - shack -c "env -i TCPREMOTEIP=\"$TCPREMOTEIP\" \"$dirname/noise\""