Patchwork configure: avoid basename usage message

login
register
mail settings
Submitter Scott Wood
Date April 8, 2011, 4:33 p.m.
Message ID <20110408163349.GA1212@schlenkerla.am.freescale.net>
Download mbox | patch
Permalink /patch/90401/
State New
Headers show

Comments

Scott Wood - April 8, 2011, 4:33 p.m.
basename prints a missing-argument error when sdlconfig is empty
and we're cross-compiling.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 configure |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
Stefan Hajnoczi - April 8, 2011, 6:56 p.m.
On Fri, Apr 08, 2011 at 11:33:49AM -0500, Scott Wood wrote:
> diff --git a/configure b/configure
> index ae97e11..c5b85fe 100755
> --- a/configure
> +++ b/configure
> @@ -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
Anthony Liguori - April 8, 2011, 8:06 p.m.
On 04/08/2011 01:56 PM, Stefan Hajnoczi wrote:
> On Fri, Apr 08, 2011 at 11:33:49AM -0500, Scott Wood wrote:
>> diff --git a/configure b/configure
>> index ae97e11..c5b85fe 100755
>> --- a/configure
>> +++ b/configure
>> @@ -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

$() is a bash-ism FYI.

Regards,

Anthony Liguori

> Then you don't need to test sdlconfig because basename will produce an
> empty string without error.
>
> Stefan
>
Scott Wood - April 8, 2011, 8:20 p.m.
On Fri, 8 Apr 2011 15:06:57 -0500
Anthony Liguori <anthony@codemonkey.ws> wrote:

> On 04/08/2011 01:56 PM, Stefan Hajnoczi wrote:
> > On Fri, Apr 08, 2011 at 11:33:49AM -0500, Scott Wood wrote:
> >> diff --git a/configure b/configure
> >> index ae97e11..c5b85fe 100755
> >> --- a/configure
> >> +++ b/configure
> >> @@ -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
> 
> $() 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

Patch

diff --git a/configure b/configure
index ae97e11..c5b85fe 100755
--- a/configure
+++ b/configure
@@ -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