git: 4fd8a69ec662 - main - pw: fix inverted condition in shell_path error handling

From: Baptiste Daroussin <bapt_at_FreeBSD.org>
Date: Fri, 05 Jun 2026 06:02:36 UTC
The branch main has been updated by bapt:

URL: https://cgit.FreeBSD.org/src/commit/?id=4fd8a69ec6623da5ef33818be134efffebe37f75

commit 4fd8a69ec6623da5ef33818be134efffebe37f75
Author:     Baptiste Daroussin <bapt@FreeBSD.org>
AuthorDate: 2026-06-04 22:12:35 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2026-06-05 06:01:35 +0000

    pw: fix inverted condition in shell_path error handling
---
 usr.sbin/pw/pw_user.c                | 2 +-
 usr.sbin/pw/tests/pw_useradd_test.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
index 413eac4882cc..dcf870ca1edc 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/pw/pw_user.c
@@ -464,7 +464,7 @@ shell_path(char const * path, char *shells[], char *sh)
 						return shellpath;
 				}
 		}
-		if (sh == NULL)
+		if (sh != NULL)
 			errx(EX_OSFILE, "can't find shell `%s' in shell paths", sh);
 		errx(EX_CONFIG, "no default shell available or defined");
 		return NULL;
diff --git a/usr.sbin/pw/tests/pw_useradd_test.sh b/usr.sbin/pw/tests/pw_useradd_test.sh
index 75e96a64ba8e..4b0778759203 100755
--- a/usr.sbin/pw/tests/pw_useradd_test.sh
+++ b/usr.sbin/pw/tests/pw_useradd_test.sh
@@ -402,7 +402,7 @@ user_add_bad_shell_body() {
 	populate_etc_skel
 
 	atf_check -s exit:0 ${PW} useradd foo -s sh
-	atf_check -s exit:78 -e ignore ${PW} useradd bar -s badshell
+	atf_check -s exit:72 -e inline:"pw: can't find shell \`badshell' in shell paths\n" ${PW} useradd bar -s badshell
 }
 
 atf_test_case user_add_already_exists