Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/usr.bin/printf When the shell being tested for builtin...



details:   https://anonhg.NetBSD.org/src/rev/f9bdfcae2c83
branches:  trunk
changeset: 433437:f9bdfcae2c83
user:      kre <kre%NetBSD.org@localhost>
date:      Fri Sep 14 19:52:23 2018 +0000

description:
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).

diffstat:

 tests/usr.bin/printf/t_builtin.sh |  29 +++++++++++++++++------------
 1 files changed, 17 insertions(+), 12 deletions(-)

diffs (45 lines):

diff -r d7790c639998 -r f9bdfcae2c83 tests/usr.bin/printf/t_builtin.sh
--- a/tests/usr.bin/printf/t_builtin.sh Fri Sep 14 19:06:53 2018 +0000
+++ b/tests/usr.bin/printf/t_builtin.sh Fri Sep 14 19:52:23 2018 +0000
@@ -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 @@
 
 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
 }
 



Home | Main Index | Thread Index | Old Index