commit d854792229fd4151b3f9abb70fa4bfaeea369563
parent d1f7167ce21da3e3f4ee051b2fdd24fc9607bbdc
Author: Toby Goodwin <LibreSoftwareDesign@gmail.com>
Date: Mon, 15 Oct 2012 00:17:17 +0100
more tidying up of errors
Diffstat:
5 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/builtins.c b/builtins.c
@@ -88,12 +88,12 @@ extern void funcall(char **av) {
}
static void arg_count(char *name) {
- fprint(2, "too many arguments to %s\n", name);
+ fprint(2, RC "too many arguments to %s\n", name);
set(FALSE);
}
static void badnum(char *num) {
- fprint(2, "%s is a bad number\n", num);
+ fprint(2, RC "`%s' is a bad number\n", num);
set(FALSE);
}
diff --git a/rc.h b/rc.h
@@ -4,6 +4,8 @@
#include <assert.h>
+#define RC "rc: "
+
/* datatypes */
#define ENV_SEP '\001'
diff --git a/trip.rc b/trip.rc
@@ -63,7 +63,7 @@ if (!~ `umask 027) fail umask reported bad value: `umask
submatch 'umask bad' 'bad umask' 'bad umask'
submatch 'umask -027' 'bad umask' 'bad umask'
submatch 'umask 999999' 'bad umask' 'bad umask'
-submatch 'umask hi there' 'too many arguments to umask' 'umask arg count'
+submatch 'umask hi there' 'rc: too many arguments to umask' 'umask arg count'
if (!~ `umask 027) fail bad umask changed umask value to `umask
@@ -85,8 +85,8 @@ rm -f 1 2
expect error from cat, closing stdin
cat >[0=]
-submatch 'cat>(1 2 3)' 'multi-word filename in redirection' 'redirection error'
-submatch 'cat>()' 'null filename in redirection' 'redirection error'
+submatch 'cat>(1 2 3)' 'rc: multi-word filename in redirection' 'redirection error'
+submatch 'cat>()' 'rc: null filename in redirection' 'redirection error'
#
# blow the input stack
@@ -226,9 +226,9 @@ bar
if (!~ $i 3)
fail return inside loop inside function failed
-submatch return 'return outside of function' 'return outside of function'
-submatch 'break 1' 'too many arguments to break' 'break arg count'
-submatch break 'break outside of loop' 'break outside of loop'
+submatch return 'rc: return outside of function' 'return outside of function'
+submatch 'break 1' 'rc: too many arguments to break' 'break arg count'
+submatch break 'rc: break outside of loop' 'break outside of loop'
for (i in 1 2 3 4 5)
if (~ $i 2)
@@ -236,7 +236,7 @@ for (i in 1 2 3 4 5)
if (!~ $i 2)
fail break out of loop
-submatch 'wait foo' 'foo is a bad number' 'bogus argument to wait'
+submatch 'wait foo' 'rc: `foo'' is a bad number' 'bogus argument to wait'
if (~ `{echo -n} ?)
fail echo -n
@@ -303,7 +303,7 @@ if (~ `{whatis limit >[2]/dev/null} builtin) {
fn cd
-submatch 'cd a b c' 'too many arguments to cd' 'cd arg count'
+submatch 'cd a b c' 'rc: too many arguments to cd' 'cd arg count'
$rc -c 'cdpath=() cd /frobnatz' >[2]/dev/null && fail 'cd to /frobnatz succeeded!?'
submatch 'cdpath='''' cd frobnatz' 'couldn''t cd to frobnatz' 'cd to frobnatz succeeded!?'
@@ -315,7 +315,7 @@ submatch 'cdpath='''' cd frobnatz' 'couldn''t cd to frobnatz' 'cd to frobnatz su
# wait
#
-submatch 'wait 1 2 3' 'too many arguments to wait' 'arg count'
+submatch 'wait 1 2 3' 'rc: too many arguments to wait' 'wait arg count'
$rc -c 'wait 1' >[2]/dev/null && fail wait 1
sleep 3&
@@ -509,8 +509,8 @@ switch (nothing) {
~ $i frobnatz || fail match '*' in switch
-submatch '()=()' 'null variable name' 'assignment diagnostic'
-submatch 'fn () {eval}' 'null function name' 'assigning null function name'
+submatch '()=()' 'rc: null variable name' 'assignment diagnostic'
+submatch 'fn () {eval}' 'rc: null function name' 'assigning null function name'
#
# prompt
diff --git a/utils.c b/utils.c
@@ -12,9 +12,9 @@
extern void pr_error(char *s, int offset) {
if (s != NULL) {
if (interactive)
- fprint(2, "%s\n", s);
+ fprint(2, RC "%s\n", s);
else
- fprint(2, "line %d: %s\n", lineno + offset, s);
+ fprint(2, RC "line %d: %s\n", lineno + offset, s);
}
}
@@ -27,9 +27,9 @@ extern void uerror(char *s) {
if (!err) err = "unknown error";
if (s)
- fprint(2, "%s: %s\n", s, err);
+ fprint(2, RC "%s: %s\n", s, err);
else
- fprint(2, "%s\n", err);
+ fprint(2, RC "%s\n", err);
}
/* Die horribly. This should never get called. Please let me know if it does. */
diff --git a/which.c b/which.c
@@ -134,7 +134,7 @@ extern char *which(char *name, bool verbose) {
}
if (verbose) {
char *n = protect(name);
- fprint(2, "rc: cannot find `%s'\n", n);
+ fprint(2, RC "cannot find `%s'\n", n);
efree(n);
}
return NULL;