diff --git a/usr.bin/xinstall/tests/install_test.sh b/usr.bin/xinstall/tests/install_test.sh index b35706521ec3..0f1f93ab4c63 100755 --- a/usr.bin/xinstall/tests/install_test.sh +++ b/usr.bin/xinstall/tests/install_test.sh @@ -32,6 +32,15 @@ copy_to_empty_body() { install testf "" } +atf_test_case copy_to_nonexistent_dir +copy_to_nonexistent_dir_body() { + local dir="/nonexistent" + + printf 'test\n123\r456\r\n789\0z' >testf + atf_check -s not-exit:0 -e match:$dir": No such file or directory" \ + install testf $dir/testf +} + copy_to_nonexistent_with_opts() { printf 'test\n123\r456\r\n789\0z' >testf atf_check install "$@" testf copyf @@ -506,6 +515,7 @@ set_optional_exec_body() atf_init_test_cases() { atf_add_test_case copy_to_empty atf_add_test_case copy_to_nonexistent + atf_add_test_case copy_to_nonexistent_dir atf_add_test_case copy_to_nonexistent_safe atf_add_test_case copy_to_nonexistent_comparing atf_add_test_case copy_to_nonexistent_safe_comparing diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c index 2823a9040b7a..d0fcda340034 100644 --- a/usr.bin/xinstall/xinstall.c +++ b/usr.bin/xinstall/xinstall.c @@ -869,7 +869,7 @@ install(const char *from_name, const char *to_name, u_long fset, u_int flags) to_fd = create_tempfile(to_name, tempfile, sizeof(tempfile)); if (to_fd < 0) - err(EX_OSERR, "%s", tempfile); + err(EX_OSERR, "%s", dirname(tempfile)); if (!devnull) { if (dostrip) { stripped = strip(tempfile, to_fd, from_name,