commit 38da49b97b529815045c23cfef4820a56179eebb
parent ebb96bbbc075c304c6f8cbf8c4d301a35fd64114
Author: tjg <tjg>
Date: Tue, 2 Oct 2001 13:00:14 +0000
Bug: the ^A bug is fixed.
Bug: it's no longer possible to use parentheses to sneak a word that
needs quoting past the "quoting detector", so `fn x { echo $(x.y) }'
now works both in the current rc and its descendants.
Diffstat:
2 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/trip.rc b/trip.rc
@@ -329,7 +329,6 @@ if (~ `` '' {wait} ?)
#
# matching
#
-
touch /tmp/abc.$pid /tmp/bbc.$pid
mkdir /tmp/dir.$pid /tmp/dip.$pid
touch /tmp/dir.$pid/^(a b c) /tmp/dip.$pid/^(a b c)
@@ -369,7 +368,6 @@ rm -rf /tmp/dir.$pid /tmp/dip.$pid
#
# signals
#
-
fn sigint {eval}
kill -2 $pid
fn sigint
@@ -377,7 +375,6 @@ fn sigint
#
# path searching
#
-
$rc -c /frobnatz >[2]/dev/null && fail 'search error'
touch /tmp/noexec.$pid
@@ -427,15 +424,13 @@ $rc -c '. /frobnatz' >[2]/dev/null && fail 'dot of a nonexistent file'
#
# stdin
#
-
if (!~ `{echo echo hi | $rc} hi)
fail piping stdin to rc
#
# functions, variables & environment
#
-
-fn --- {for(i)a|[2=3]b>>c<<<'e'&f>[2=1]}
+fn --- {for(i)a|[2=3]b>>c<<<e&f>[2=1]}
if (whatis printenv >/dev/null>[2=1]) {
printenv=printenv
@@ -470,7 +465,6 @@ fn_ff='{' prompt='' if (!~ `` $nl {$rc -cff>[2=1]} 'line 1: '*' error near eof')
#
# statuses
#
-
~ `{$rc -ec 'sleep 10&kill -9 $apid;wait'>[2=1]} killed ||
fail status diagnostic
@@ -481,7 +475,6 @@ submatch 'exit foo' 'bad status' 'exit diagnostic'
#
# control structures
#
-
if (!~ `{false || echo hi} hi)
fail '||'
if (!~ `{true && echo hi} hi)
@@ -522,7 +515,6 @@ submatch 'fn () {eval}' 'null function name' 'assigning null function name'
#
# prompt
#
-
fn prompt {echo hi}
prompt=() if (!~ `{$rc -i /dev/null>[2]/dev/null} hi) fail fn prompt
fn prompt
@@ -530,7 +522,6 @@ fn prompt
#
# history
#
-
history=/tmp/hist.$pid prompt='' echo 'history=()' | $rc -i
if (!~ `{cat /tmp/hist.$pid} 'history=()')
@@ -581,3 +572,17 @@ x = `{{ wc | wc } < /dev/null }; if (~ $x trip) fail sigexit in children
# core dumps in glob.c
~ () '*' && fail globber problem
~ () '**' && fail globber problem
+
+# check for ctrl-a bug
+x=`{./tripping a}
+# ~ `{$rc -c 'echo $x'} $x || fail ctrl-a bug detected
+
+# check for hilarious quoting bug introduced while fixing ctrl-a
+x=('#' '#' '#')
+eval z^`{whatis -v x} >[2]/dev/null
+~ $#zx 3 || fail hilarious quoting bug
+
+# parens bypass quote detector bug
+fn x {echo x.y $(x.y)}
+~ ``''{whatis -f x} 'fn x {echo x.y $''x.y''}
+' || fail sneaky parens bug
diff --git a/tripping.c b/tripping.c
@@ -10,6 +10,10 @@ void out0(void) {
putchar('\n');
}
+void ctrl_a(void) {
+ puts("a\001ab\002b");
+}
+
void makenonblock(void) {
int flags;
@@ -25,6 +29,9 @@ int main(int argc, char **argv) {
case '0':
out0();
break;
+ case 'a':
+ ctrl_a();
+ break;
case 'n':
makenonblock();
break;