svn commit: r201431 - in head: bin/sh
tools/regression/bin/sh/builtins
Jilles Tjoelker
jilles at FreeBSD.org
Sun Jan 3 15:01:39 UTC 2010
Author: jilles
Date: Sun Jan 3 15:01:38 2010
New Revision: 201431
URL: http://svn.freebsd.org/changeset/base/201431
Log:
sh: Send the "not found" message for builtin <cmd> to redirected fd 2.
Added:
head/tools/regression/bin/sh/builtins/builtin1.0 (contents, props changed)
Modified:
head/bin/sh/eval.c
Modified: head/bin/sh/eval.c
==============================================================================
--- head/bin/sh/eval.c Sun Jan 3 13:59:59 2010 (r201430)
+++ head/bin/sh/eval.c Sun Jan 3 15:01:38 2010 (r201431)
@@ -722,9 +722,10 @@ evalcommand(union node *cmd, int flags,
break;
if ((cmdentry.u.index = find_builtin(*argv,
&cmdentry.special)) < 0) {
- out2fmt_flush("%s: not found\n", *argv);
- exitstatus = 127;
- return;
+ cmdentry.u.index = BLTINCMD;
+ argv--;
+ argc++;
+ break;
}
if (cmdentry.u.index != BLTINCMD)
break;
@@ -944,12 +945,17 @@ prehash(union node *n)
*/
/*
- * No command given, or a bltin command with no arguments.
+ * No command given, a bltin command with no arguments, or a bltin command
+ * with an invalid name.
*/
int
-bltincmd(int argc __unused, char **argv __unused)
+bltincmd(int argc, char **argv)
{
+ if (argc > 1) {
+ out2fmt_flush("%s: not found\n", argv[1]);
+ return 127;
+ }
/*
* Preserve exitstatus of a previous possible redirection
* as POSIX mandates
Added: head/tools/regression/bin/sh/builtins/builtin1.0
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/tools/regression/bin/sh/builtins/builtin1.0 Sun Jan 3 15:01:38 2010 (r201431)
@@ -0,0 +1,31 @@
+# $FreeBSD$
+
+failures=0
+
+check() {
+ if ! eval "[ $* ]"; then
+ echo "Failed: $*"
+ : $((failures += 1))
+ fi
+}
+
+builtin : || echo "Bad return code at $LINENO"
+builtin true || echo "Bad return code at $LINENO"
+builtin ls 2>/dev/null && echo "Bad return code at $LINENO"
+check '"$(builtin pwd)" = "$(pwd)"'
+check '-z "$(builtin :)"'
+check '-z "$(builtin true)"'
+check '-z "$( (builtin nosuchtool) 2>/dev/null)"'
+check '-z "$(builtin nosuchtool 2>/dev/null)"'
+check '-z "$(builtin nosuchtool 2>/dev/null; :)"'
+check '-z "$( (builtin ls) 2>/dev/null)"'
+check '-z "$(builtin ls 2>/dev/null)"'
+check '-z "$(builtin ls 2>/dev/null; :)"'
+check '-n "$( (builtin nosuchtool) 2>&1)"'
+check '-n "$(builtin nosuchtool 2>&1)"'
+check '-n "$(builtin nosuchtool 2>&1; :)"'
+check '-n "$( (builtin ls) 2>&1)"'
+check '-n "$(builtin ls 2>&1)"'
+check '-n "$(builtin ls 2>&1; :)"'
+
+exit $((failures > 0))
More information about the svn-src-head
mailing list