coreutils
[Top][All Lists]
Advanced

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

Re: [coreutils] [PATCH] tests: avoid portability problem with dash vs. l


From: Jim Meyering
Subject: Re: [coreutils] [PATCH] tests: avoid portability problem with dash vs. local v=$splittable_val
Date: Mon, 08 Nov 2010 13:20:32 +0100

Pádraig Brady wrote:
> No time now. It's a very minor issue.
> I'll look after the release.
>
> p.s. My laptop is a bit mangled ATM

Ouch!  Good luck.

FTR, this does what I intended, but isn't complete either,
since it doesn't check the max_n_tries parameter.
I'm debating how much internal arg checking is warranted
for test-only code like this.

>From 21ff95d56601735e6db0c1235dee627f15e5eb1a Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Mon, 8 Nov 2010 13:11:05 +0100
Subject: [PATCH] tests: diagnose potential internal error

* tests/init.cfg (retry_delay_): Fail upon invalid init_delay,
and remove now-unneeded quotes in awk invocation.
---
 tests/init.cfg |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/tests/init.cfg b/tests/init.cfg
index 97dad17..ad46079 100644
--- a/tests/init.cfg
+++ b/tests/init.cfg
@@ -383,17 +383,21 @@ working_umask_or_skip_()
 retry_delay_()
 {
   local test_func=$1
   local init_delay=$2
   local max_n_tries=$3

+  case $init_delay in
+  ''|[^+.0-9]) fail_ "invalid delay: $init_delay; internal error"
+  esac
+
   local attempt=1
   local num_sleeps=$attempt
   local time_fail
   while test $attempt -le $max_n_tries; do
-    local delay=$($AWK -v n=$num_sleeps -v s="$init_delay" \
+    local delay=$($AWK -v n=$num_sleeps -v s=$init_delay \
                   'BEGIN { print s * n }')
     "$test_func" "$delay" && { time_fail=0; break; } || time_fail=1
     attempt=$(expr $attempt + 1)
     num_sleeps=$(expr $num_sleeps '*' 2)
   done
   test "$time_fail" = 0
--
1.7.3.2.332.gec4f8



reply via email to

[Prev in Thread] Current Thread [Next in Thread]