diff options
author | jilles <jilles@FreeBSD.org> | 2012-01-13 23:32:27 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2012-01-13 23:32:27 +0000 |
commit | 69e6f0d41657559b7c7414462d57136cc7184f41 (patch) | |
tree | 4d216d3f8f08c09184dfe315554ff5b7157a73fb /tools/regression/bin | |
parent | a97c56fa2ab8649a7f6695df50ab3c6cc735d54f (diff) | |
download | FreeBSD-src-69e6f0d41657559b7c7414462d57136cc7184f41.zip FreeBSD-src-69e6f0d41657559b7c7414462d57136cc7184f41.tar.gz |
sh: Properly show "Not a directory" error in cd builtin.
The errno message display added in r222292 did not take attempting to
cd to a non-directory or something that cannot be stat()ed into account.
PR: bin/164070
MFC after: 10 days
Diffstat (limited to 'tools/regression/bin')
-rw-r--r-- | tools/regression/bin/sh/builtins/cd8.0 | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/regression/bin/sh/builtins/cd8.0 b/tools/regression/bin/sh/builtins/cd8.0 new file mode 100644 index 0000000..a68f77f --- /dev/null +++ b/tools/regression/bin/sh/builtins/cd8.0 @@ -0,0 +1,26 @@ +# $FreeBSD$ + +# The exact wording of the error message is not standardized, but giving +# a description of the errno is useful. + +LC_ALL=C +export LC_ALL +r=0 + +t() { + exec 3>&1 + errmsg=`cd "$1" 2>&1 >&3 3>&-` + exec 3>&- + case $errmsg in + *[Nn]ot\ a\ directory*) + ;; + *) + printf "Wrong error message for %s: %s\n" "$1" "$errmsg" + r=3 + ;; + esac +} + +t /dev/tty +t /dev/tty/x +exit $r |