Skip to contentSkip to conversation

configure: avoid basename usage message

PATCH Superseded Scott Wood 3 participants 6 messages Apr 8, 2011 – Apr 9, 2011

lore
Share & tools
lore

Scott Wood

author
#0 lore raw

PATCH 1/1 configure: avoid basename usage message

basename prints a missing-argument error when sdlconfig is empty and we're cross-compiling.

---
 configure |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
configure +2 -1
index ae97e11..c5b85fe 100755
@@ -1233,7 +1233,8 @@ else
   fi
   sdl=no
 fi
-if test -n "$cross_prefix" && test "`basename $sdlconfig`" = sdl-config; then
+if test -n "$cross_prefix" -a -n "$sdlconfig" && \
+   test "`basename $sdlconfig`" = sdl-config; then
   echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
 fi
 
Signature · 1 line
1.7.1
#1 lore raw

configure else · line 1237

Quoted 11 lines · Scott Wood
configure +2 -1
index ae97e11..c5b85fe 100755
@@ -1233,7 +1233,8 @@ else
   fi
   sdl=no
 fi
-if test -n "$cross_prefix" && test "`basename $sdlconfig`" = sdl-config; then
+if test -n "$cross_prefix" -a -n "$sdlconfig" && \
+   test "`basename $sdlconfig`" = sdl-config; then

Instead of doing test -n "$sdlconfig" first with short-circuit evaluation, I think would should do:

test $(basename "$sdlconfig") = sdl-config

Then you don't need to test sdlconfig because basename will produce an empty string without error.

Stefan

author
#2 lore raw

PATCH v2 1/1 configure: avoid basename usage message

basename prints a missing-argument error when sdlconfig is empty and we're cross-compiling.

---
v2: quote the input to basename rather than introduce an extra test, as suggested by Stefan.

 configure |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
configure +1 -1
index ae97e11..2bb3faa 100755
@@ -1233,7 +1233,7 @@ else
   fi
   sdl=no
 fi
-if test -n "$cross_prefix" && test "`basename $sdlconfig`" = sdl-config; then
+if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
   echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
 fi
 
Signature · 1 line
1.7.1
#3 lore raw
Quoted 10 lines · Scott Wood

basename prints a missing-argument error when sdlconfig is empty and we're cross-compiling.

---
v2: quote the input to basename rather than introduce an extra test, as suggested by Stefan.

 configure |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

I have merged into the trivial patches tree since $() is POSIX and we already use it in ./configure:
git://repo.or.cz/qemu/stefanha.git trivial-patches

A pull request will be sent to merge this into qemu.git. For more information, see http://wiki.qemu.org/Contribute/TrivialPatches.

Stefan

#4 lore raw
In reply to Stefan Hajnoczi
Quoted 15 lines · Stefan Hajnoczi

configure else · line 1237

Quoted 11 lines · Scott Wood
configure +2 -1
index ae97e11..c5b85fe 100755
@@ -1233,7 +1233,8 @@ else
    fi
    sdl=no
  fi
-if test -n "$cross_prefix"&&  test "`basename $sdlconfig`" = sdl-config; then
+if test -n "$cross_prefix" -a -n "$sdlconfig"&&  \
+   test "`basename $sdlconfig`" = sdl-config; then

Instead of doing test -n "$sdlconfig" first with short-circuit evaluation, I think would should do:

Quoted 1 line

test $(basename "$sdlconfig") = sdl-config

$() is a bash-ism FYI.

Regards,

Anthony Liguori

Quoted 5 lines

Then you don't need to test sdlconfig because basename will produce an empty string without error.

Stefan

author
#5 lore raw
Quoted 16 lines · On Fri, 8 Apr 2011 15:06:57 -0500 Anthony Liguori <[email protected]> wrote:
Quoted 15 lines · Stefan Hajnoczi

configure else · line 1237

Quoted 11 lines · Scott Wood
configure +2 -1
index ae97e11..c5b85fe 100755
@@ -1233,7 +1233,8 @@ else
    fi
    sdl=no
  fi
-if test -n "$cross_prefix"&&  test "`basename $sdlconfig`" = sdl-config; then
+if test -n "$cross_prefix" -a -n "$sdlconfig"&&  \
+   test "`basename $sdlconfig`" = sdl-config; then

Instead of doing test -n "$sdlconfig" first with short-circuit evaluation, I think would should do:

Quoted 3 lines
Quoted 1 line

test $(basename "$sdlconfig") = sdl-config

$() is a bash-ism FYI.

See section 2.6.3 of
http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html

And I've tested that it works in dash.

-Scott