Skip to contentSkip to conversation

runqemu: fix the tests for core-image-*

PATCH Applied Peter Seebach 3 participants 4 messages May 14, 2012 – May 16, 2012

lore
Share & tools
lore
#0 lore raw

cover runqemu: fix the tests for core-image-*

This replaces the =~ tests with a dash-friendly shell idiom which is, IMHO, comparably readable (I actually like it better) and also works on more versions of bash.

A side note: Do we really need a more complicated test instead of just "*core-image-*"?

The following changes since commit 36d1717e2ad4ca1620ee9f01b524b5ff2f499b26:
Paul Eggleton (1):
classes/rootfs_*: fix splitting package dependency strings

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib seebs/cleanup
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=seebs/cleanup

Peter Seebach (1):
runqemu: replace bashism with working shell idiom

 scripts/runqemu |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)
#1 lore raw

PATCH 1/1 runqemu: replace bashism with working shell idiom

The =~ operator is not one of my favorites, not just due to portability issues, but because it's not well known, and a lot of people might not expect a regex operator.

The canonical shell idiom for this is to use case with alternation and wildcards. As a side note, if you are matching anything containing core-image-sato, you don't need to also check for core-image-sato-sdk.

---
 scripts/runqemu |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)
scripts/runqemu +7 -6
index 305e46a..fc7363f 100755
@@ -300,14 +300,15 @@ findimage() {
     # recently created one is the one we most likely want to boot.
     filenames=`ls -t $where/*-image*$machine.$extension 2>/dev/null | xargs`
     for name in $filenames; do
-        if [ "$name" =~ core-image-sato-sdk -o \
-              "$name" =~ core-image-sato     -o \
-              "$name" =~ core-image-lsb      -o \
-              "$name" =~ core-image-basic    -o \
-              "$name" =~ core-image-minimal ]; then
+        case $name in
+        *core-image-sato* | \
+        *core-image-lsb* | \
+        *core-image-basic* | \
+        *core-image-minimal* )
             ROOTFS=$name
             return
-        fi	
+            ;;
+        esac
     done
 
     echo "Couldn't find a $machine rootfs image in $where."
Signature · 1 line
1.7.0.4
Acked-by on v1 1/1
#2 lore raw

Re: [PATCH 1/1] runqemu: replace bashism with working shell idiom

Quoted 9 lines · Peter Seebach

The =~ operator is not one of my favorites, not just due to portability issues, but because it's not well known, and a lot of people might not expect a regex operator.

The canonical shell idiom for this is to use case with alternation and wildcards. As a side note, if you are matching anything containing core-image-sato, you don't need to also check for core-image-sato-sdk.

Thank you, Peter.

Quoted 30 lines
---
  scripts/runqemu |   13 +++++++------
  1 files changed, 7 insertions(+), 6 deletions(-)
scripts/runqemu +7 -6
index 305e46a..fc7363f 100755
@@ -300,14 +300,15 @@ findimage() {
      # recently created one is the one we most likely want to boot.
      filenames=`ls -t $where/*-image*$machine.$extension 2>/dev/null | xargs`
      for name in $filenames; do
-        if [ "$name" =~ core-image-sato-sdk -o \
-              "$name" =~ core-image-sato     -o \
-              "$name" =~ core-image-lsb      -o \
-              "$name" =~ core-image-basic    -o \
-              "$name" =~ core-image-minimal ]; then
+        case $name in
+        *core-image-sato* | \
+        *core-image-lsb* | \
+        *core-image-basic* | \
+        *core-image-minimal* )
              ROOTFS=$name
              return
-        fi	
+            ;;
+        esac
      done
 
      echo "Couldn't find a $machine rootfs image in $where."
Signature · 3 lines
Scott Garman
Embedded Linux Engineer - Yocto Project
Intel Open Source Technology Center
Applied
#3 lore raw
In reply to Peter Seebach
Quoted 19 lines · Peter Seebach

This replaces the =~ tests with a dash-friendly shell idiom which is, IMHO, comparably readable (I actually like it better) and also works on more versions of bash.

A side note: Do we really need a more complicated test instead of just "*core-image-*"?

The following changes since commit 36d1717e2ad4ca1620ee9f01b524b5ff2f499b26:
Paul Eggleton (1):
classes/rootfs_*: fix splitting package dependency strings

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib seebs/cleanup
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=seebs/cleanup

Peter Seebach (1):
runqemu: replace bashism with working shell idiom

Quoted 9 lines
  scripts/runqemu |   13 +++++++------
  1 files changed, 7 insertions(+), 6 deletions(-)

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

Merged into OE-Core

Thanks
Sau!