Module Name: src Committed By: kre Date: Fri Sep 14 19:52:23 UTC 2018
Modified Files: src/tests/usr.bin/printf: t_builtin.sh Log Message: When the shell being tested for builtin printf supports "type -t" use it to test if printf is built in, it is must more reliable that guessing at the output format and message of "type" (without -t). To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/printf/t_builtin.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/usr.bin/printf/t_builtin.sh diff -u src/tests/usr.bin/printf/t_builtin.sh:1.3 src/tests/usr.bin/printf/t_builtin.sh:1.4 --- src/tests/usr.bin/printf/t_builtin.sh:1.3 Mon Sep 10 15:02:11 2018 +++ src/tests/usr.bin/printf/t_builtin.sh Fri Sep 14 19:52:23 2018 @@ -1,4 +1,4 @@ -# $NetBSD: t_builtin.sh,v 1.3 2018/09/10 15:02:11 kre Exp $ +# $NetBSD: t_builtin.sh,v 1.4 2018/09/14 19:52:23 kre Exp $ # # Copyright (c) 2018 The NetBSD Foundation, Inc. # All rights reserved. @@ -98,19 +98,24 @@ Not_builtin() setup() { - case "$(unset LANG LC_ALL LC_NUMERIC LC_CTYPE LC_MESSAGES - ${TEST_SH} -c 'type printf' 2>&1 )" in - - ( *[Bb]uiltin* | *[Bb]uilt[-\ ][Ii]n* ) - # nothing here, it all happens below. - ;; + # If the shell being used for its printf supports "type -t", use it + if B=$( ${TEST_SH} -c 'type -t printf' 2>/dev/null ) + then + case "$B" in + ( builtin ) return 0;; + esac + else + # We get here if type -t is not supported, or it is, + # but printf is completely unknown. No harm trying again. - (*) Tests= - define Not_builtin 'Dummy test to skip when no printf builtin' - return 1 - ;; - esac + case "$( unset LANG LC_ALL LC_NUMERIC LC_CTYPE LC_MESSAGES + ${TEST_SH} -c 'type printf' 2>&1 )" in + ( *[Bb]uiltin* | *[Bb]uilt[-\ ][Ii]n* ) return 0;; + esac + fi + Tests= + define Not_builtin 'Dummy test to skip when no printf builtin' return 0 }