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/ed593a21b8cb
branches:  trunk
changeset: 835876:ed593a21b8cb
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 d1e973d0c247 -r ed593a21b8cb 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