Hi,

The greeting-2 test uses the "set - ARGS" idiom which once was thought to be
portable. It no longer is:

https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Limitations-of-Builtins.html
says
"Avoid ‘set -’, e.g., ‘set - $my_list’. Posix no longer requires support for
 this command, and in traditional shells ‘set - $my_list’ resets the -v and -x
 options, which makes scripts harder to debug."

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
says
"If the first argument is '-', the results are unspecified."

Find attached a patch (tested).

>From cabaa81becf9b6da89c5408b1f05035a5ba39f4a Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Wed, 14 Dec 2016 19:23:31 +0100
Subject: [PATCH] Make the greeting-2 test POSIX compliant and traceable
 through "sh -x".

* tests/greeting-2: Don't use the "set - ARGS" idiom. References:
https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Limitations-of-Builtins.html
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
---
 tests/greeting-2 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/greeting-2 b/tests/greeting-2
index f7d69e1..ab6b459 100755
--- a/tests/greeting-2
+++ b/tests/greeting-2
@@ -2,7 +2,7 @@
 # Test very long --greeting argument, and also show skipping a test.
 # (And one way to compute full moons.)
 #
-# Copyright (C) 2001, 2006, 2014, 2015 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2006, 2014-2016 Free Software Foundation, Inc.
 #
 # Copying and distribution of this file, with or without modification,
 # are permitted in any medium without royalty provided the copyright
@@ -16,7 +16,7 @@ Wuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
 EOF
 
 # Werewolves cry at full moon only.
-set - `TZ=GMT date +"%Y %j %H %M %S"`
+set x `TZ=GMT date +"%Y %j %H %M %S"`; shift
 year=$1; day=$2; hours=$3; minutes=$4; seconds=$5
 years_since_2000=`expr $year - 2000`
 days_since_2000=`expr '(' $years_since_2000 '*' 365 ')' + '(' '(' $years_since_2000 - 1 ')' / 4 ')' + $day`
-- 
2.6.4

Reply via email to