yeah, return works.

patch attached (on the assumption that `return` also works on your older bash).

On Fri, Dec 28, 2018 at 11:38 AM Rob Landley <[email protected]> wrote:
>
> On 12/27/18 6:38 PM, enh wrote:
> > On Thu, Dec 27, 2018 at 12:14 PM Rob Landley <[email protected]> wrote:
> >> If we're not in a loop, continue should throw an error, then fall through 
> >> to the
> >> exit. (That's what it does here...) You don't want to exit out of a loop 
> >> because
> >> the loop will stop, but continue's a noisy NOP if you're not in a loop...
> >>
> >> Did bash grow a bug where redirecting stderr of continue breaks?
> >
> > no, it seems to be what i suggested before: bash doesn't believe it's
> > in a loop, presumably because of the intervening function.
>
> Possibly the continue should be a return now?
>
> > the error
> > is `continue: only meaningful in a 'for', 'while', or 'until' loop`.
> > (there are 'until' loops?)
>
> I have no idea, but should probably look it up for toysh.
>
> Rob
From 513399ad9a7dea56b9fb70302328473610176d20 Mon Sep 17 00:00:00 2001
From: Elliott Hughes <[email protected]>
Date: Mon, 7 Jan 2019 16:41:53 -0800
Subject: [PATCH] Use `return` rather than `continue` to make bash 4.4 happy.

Otherwise we get this error:

  continue: only meaningful in a 'for', 'while', or 'until' loop
---
 tests/chattr.test   | 2 +-
 tests/chgrp.test    | 2 +-
 tests/chown.test    | 2 +-
 tests/groupadd.test | 2 +-
 tests/groupdel.test | 2 +-
 tests/hostname.test | 2 +-
 tests/ifconfig.test | 2 +-
 tests/losetup.test  | 2 +-
 tests/sh.test       | 2 +-
 tests/useradd.test  | 2 +-
 10 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/tests/chattr.test b/tests/chattr.test
index 067014df..04005a7a 100755
--- a/tests/chattr.test
+++ b/tests/chattr.test
@@ -7,7 +7,7 @@
 if [ "$(id -u)" -ne 0 ]
 then
   echo "$SHOWSKIP: chattr (not root)"
-  continue 2>/dev/null
+  return 2>/dev/null
   exit
 fi
 
diff --git a/tests/chgrp.test b/tests/chgrp.test
index 16cd776a..65820361 100755
--- a/tests/chgrp.test
+++ b/tests/chgrp.test
@@ -5,7 +5,7 @@
 if [ "$(id -u)" -ne 0 ]
 then
   echo "$SHOWSKIP: chgrp (not root)"
-  continue 2>/dev/null
+  return 2>/dev/null
   exit
 fi
 
diff --git a/tests/chown.test b/tests/chown.test
index 95ad727a..56eed81e 100755
--- a/tests/chown.test
+++ b/tests/chown.test
@@ -5,7 +5,7 @@
 if [ "$(id -u)" -ne 0 ]
 then
   echo "$SHOWSKIP: chown (not root)"
-  continue 2>/dev/null
+  return 2>/dev/null
   exit
 fi
 
diff --git a/tests/groupadd.test b/tests/groupadd.test
index 6161ee2f..1ca018d1 100755
--- a/tests/groupadd.test
+++ b/tests/groupadd.test
@@ -7,7 +7,7 @@
 if [ "$(id -u)" -ne 0 ]
 then
   echo "$SHOWSKIP: groupadd (not root)"
-  continue 2>/dev/null
+  return 2>/dev/null
   exit
 fi
 
diff --git a/tests/groupdel.test b/tests/groupdel.test
index 94edcf90..0bd4d38a 100755
--- a/tests/groupdel.test
+++ b/tests/groupdel.test
@@ -8,7 +8,7 @@
 if [ "$(id -u)" -ne 0 ]
 then
   echo "$SHOWSKIP: groupdel (not root)"
-  continue 2>/dev/null
+  return 2>/dev/null
   exit
 fi
 
diff --git a/tests/hostname.test b/tests/hostname.test
index 80f94405..ba65a398 100755
--- a/tests/hostname.test
+++ b/tests/hostname.test
@@ -10,7 +10,7 @@ testing "get" "hostname" "$HOST\n" "" ""
 if [ "$(id -u)" -ne 0 ]
 then
   echo "$SHOWSKIP: groupdel (not root)"
-  continue 2>/dev/null
+  return 2>/dev/null
   exit
 fi
 
diff --git a/tests/ifconfig.test b/tests/ifconfig.test
index d82cd4af..34b84b73 100755
--- a/tests/ifconfig.test
+++ b/tests/ifconfig.test
@@ -24,7 +24,7 @@
 if [ "$(id -u)" -ne 0 ]
 then
   echo "$SHOWSKIP: ifconfig (not root)"
-  continue 2>/dev/null
+  return 2>/dev/null
   exit
 fi
 
diff --git a/tests/losetup.test b/tests/losetup.test
index c9292503..f30a0fe2 100755
--- a/tests/losetup.test
+++ b/tests/losetup.test
@@ -5,7 +5,7 @@
 if [ "$(id -u)" -ne 0 ]
 then
   echo "$SHOWSKIP: losetup (not root)"
-  continue 2>/dev/null
+  return 2>/dev/null
   exit
 fi
 
diff --git a/tests/sh.test b/tests/sh.test
index 1d228dcf..875a0df8 100755
--- a/tests/sh.test
+++ b/tests/sh.test
@@ -7,7 +7,7 @@
 if [ -z "$(which bash)" ]
 then
   echo "$SHOWSKIP: no bash alias"
-  continue 2>/dev/null
+  return 2>/dev/null
   exit
 fi
 
diff --git a/tests/useradd.test b/tests/useradd.test
index d0b68ee6..1567f2f1 100755
--- a/tests/useradd.test
+++ b/tests/useradd.test
@@ -8,7 +8,7 @@
 if [ "$(id -u)" -ne 0 ]
 then
   echo "$SHOWSKIP: useradd (not root)"
-  continue 2>/dev/null
+  return 2>/dev/null
   exit
 fi
 
-- 
2.20.1.97.g81188d93c3-goog

_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to