All of lore.kernel.org
 help / color / mirror / Atom feed
From: Carlos Santos <casantos@datacom.ind.br>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH v2 2/4] core: allow check-host-cmake.sh to try several candidates
Date: Sun, 7 May 2017 12:28:16 -0300 (BRT)	[thread overview]
Message-ID: <401111742.21785804.1494170896679.JavaMail.zimbra@datacom.ind.br> (raw)
In-Reply-To: <20170507094706.GB2949@scaer>

> From: "Yann E. MORIN" <yann.morin.1998@free.fr>
> To: "Carlos Santos" <casantos@datacom.ind.br>
> Cc: buildroot at buildroot.org
> Sent: Sunday, May 7, 2017 6:47:06 AM
> Subject: Re: [PATCH v2 2/4] core: allow check-host-cmake.sh to try several candidates

> Carlos, All,
---8<---
>> +    # Discard the candidate if no version can be obtained
>> +    version="$(${cmake} --version \
>> +               |sed -r -e '/.* ([[:digit:]]+\.[[:digit:]]+).*$/!d;' \
>> +                       -e 's//\1/'
>> +              )"
>> +    [ -n "${version}" ] || continue
> 
> ... here: the check that version is not empty is new, and semantically
> it looks like it should have been in a spearate patch (prossibly before
> that one).
> 
> Unless it is the act of testing multiple candidates that introduces a
> case where the version is empty, but I fil to see how that would be.

The problem here is that if $version is empty both $major and $minor
become empty too and the test below emits an annoying error message.
Example (commenting the '[ -n "${version}" ] || continue' line):

    $ sh check-host-cmake.sh 3.1 python
    Python 2.7.12
    check-host-cmake.sh: 35: [: -gt: unexpected operator
    check-host-cmake.sh: 38: [: -eq: unexpected operator

Raising even more the paranoia level, the script is also fragile in
other aspects, e.g

    $ bash --version
    GNU bash, version 4.3.46(1)-release (x86_64-pc-linux-gnu)
    ---8<---
    $  sh check-host-cmake.sh 3.1 bash
    /bin/bash
    $ cat --version
    cat (GNU coreutils) 8.25
    ---8<---
    $ sh check-host-cmake.sh 3.1 cat
    /bin/cat

It is so fragile that I'm tempted to replace the regex by a
stricter one. Example:

    $ cmake --version | sed -n -r -e 's/^cmake version ([[:digit:]]+\.[[:digit:]]+).*$/\1/p'
    2.8
    $ cmake3 --version | sed -n -r -e 's/^cmake version ([[:digit:]]+\.[[:digit:]]+).*$/\1/p'
    3.6

-- 
Carlos Santos (Casantos) - DATACOM, P&D
?The greatest triumph that modern PR can offer is the transcendent 
success of having your words and actions judged by your reputation, 
rather than the other way about.? ? Christopher Hitchens

  reply	other threads:[~2017-05-07 15:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-07  4:32 [Buildroot] [PATCH v2 1/4] core: reverse the argument order in check-host-cmake Carlos Santos
2017-05-07  4:32 ` [Buildroot] [PATCH v2 2/4] core: allow check-host-cmake.sh to try several candidates Carlos Santos
2017-05-07  9:47   ` Yann E. MORIN
2017-05-07 15:28     ` Carlos Santos [this message]
2017-05-07 16:11       ` Yann E. MORIN
2017-05-08 17:14         ` Carlos Santos
2017-05-07  4:32 ` [Buildroot] [PATCH v2 3/4] core: allow having a list of "cmake" candidates Carlos Santos
2017-05-07  4:32 ` [Buildroot] [PATCH v2 4/4] core: add "cmake3" to the list of cmake candidates Carlos Santos
2017-05-07  9:40 ` [Buildroot] [PATCH v2 1/4] core: reverse the argument order in check-host-cmake Yann E. MORIN
2017-06-24 19:46 ` Thomas Petazzoni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=401111742.21785804.1494170896679.JavaMail.zimbra@datacom.ind.br \
    --to=casantos@datacom.ind.br \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.