From 3a5752218da1c7687fb7d9f4d73d17ced7f63237 Mon Sep 17 00:00:00 2001 From: Johnothan King Date: Wed, 10 Nov 2021 16:58:32 -0800 Subject: [PATCH] Shorten command name used to test ENAMETOOLONG exit status (#333) A change in FreeBSD 13 now causes extremely long command names to exit with errno set to E2BIG if the name can't fit in the list of arguments. This was causing the regression tests for ENAMETOOLONG to fail on FreeBSD 13 because the exit status for these errors differ (ENAMETOOLONG uses status 127 while E2BIG uses status 126). src/cmd/ksh93/tests/path.sh: - To fix the failing regression tests, the command name has been shortened to twice the length of NAME_MAX. This length is still long enough to trigger an ENAMETOOLONG error without causing an E2BIG failure on FreeBSD 13. Fixes https://github.com/ksh93/ksh/issues/331 --- src/cmd/ksh93/tests/path.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cmd/ksh93/tests/path.sh b/src/cmd/ksh93/tests/path.sh index c4255ae21..3f36f72df 100755 --- a/src/cmd/ksh93/tests/path.sh +++ b/src/cmd/ksh93/tests/path.sh @@ -879,7 +879,8 @@ got=$? "(expected $exp, got $got)" # Tests for attempting to use a command name that's too long. -long_cmd=$(awk -v ORS= 'BEGIN { for(i=0;i<500;i++) print "xxxxxxxxxx"; }') +name_max=$(builtin getconf 2>/dev/null; getconf NAME_MAX . 2>/dev/null || echo 255) +long_cmd="$(awk -v ORS= 'BEGIN { for(i=0;i<'$name_max';i++) print "xx"; }')" exp=127 PATH=$PWD $SHELL -c "$long_cmd" > /dev/null 2>&1 got=$?