tests: adjust shell syntax that breaks AIX /bin/sh

Collin Funk <[email protected]>
Newsgroups gmane.comp.gnu.findutils.bugs
Message-ID <[email protected]>
On AIX, /bin/sh causes a testsuite failure with an output like this:

    Running /home/collinfunk/findutils-4.10.0.40-d4417/find/testsuite/find.gnu/execdir-multiple.exp ...
    FAIL: execdir-multiple.new-O0, ./runme[6]: syntax error at line 7 : `newline or ;' unexpected
    ./runme[6]: syntax error at line 7 : `newline or ;' unexpected
    ./runme[6]: syntax error at line 7 : `newline or ;' unexpected
    ./runme[6]: syntax error at line 7 : `newline or ;' unexpected

Here is a small test program to show the issue:

    $ cat test.sh 
    #!/bin/sh
    for arg;
    do
      echo "$arg"
    done
    $ ./test.sh a b c
    test.sh[3]: 0403-057 Syntax error at line 4 : `newline or ;' is not expected.

But, if we move the 'do' AIX /bin/sh no longer chokes:

    $ cat test.sh 
    #!/bin/sh
    for arg; do
      echo "$arg"
     done
    bash-5.2$ ./test.sh a b c
    a
    b
    c

Normally I don't think this is worth fixing. But since it only affects
one test case I have attached a patch that fixes it.

Collin
0001-tests-adjust-shell-syntax-that-breaks-AIX-bin-sh.patch (text/x-patch, 824 B)
From c46de123b5e876ad7c50db113551f04d04faf5b1 Mon Sep 17 00:00:00 2001
From: Collin Funk <[email protected]>
Date: Sat, 25 Jan 2025 21:53:17 -0800
Subject: [PATCH] tests: adjust shell syntax that breaks AIX /bin/sh

* find/testsuite/find.gnu/execdir-multiple.exp: Move the 'do' of a for
loop to the same line so AIX doesn't fail.
---
 find/testsuite/find.gnu/execdir-multiple.exp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/find/testsuite/find.gnu/execdir-multiple.exp b/find/testsuite/find.gnu/execdir-multiple.exp
index f292fffa..4ce23c3d 100644
--- a/find/testsuite/find.gnu/execdir-multiple.exp
+++ b/find/testsuite/find.gnu/execdir-multiple.exp
@@ -22,8 +22,7 @@ set -e
 here=`pwd`
 d=`basename $here`
 
-for arg;
-do
+for arg; do
   echo "$d" "$arg"
 done | LC_ALL=C sort
 }
-- 
2.48.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.