mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-28 09:02:44 +00:00
sh: Send the "not found" message for builtin <cmd> to redirected fd 2.
This commit is contained in:
parent
593a1aea1a
commit
dc82a6f600
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=201431
@ -722,9 +722,10 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
|
||||
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
|
||||
|
31
tools/regression/bin/sh/builtins/builtin1.0
Normal file
31
tools/regression/bin/sh/builtins/builtin1.0
Normal file
@ -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))
|
Loading…
Reference in New Issue
Block a user