Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
To: Jonah Petri <jonah@petri.us>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	buildroot@buildroot.org,
	Giulio Benetti <giulio.benetti@benettiengineering.com>,
	Romain Naour <romain.naour@gmail.com>,
	Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Subject: Re: [Buildroot] [PATCH v3 1/1] toolchain: handle toolchains with multiple ld*.so.* files
Date: Mon, 30 Aug 2021 10:45:14 +0200	[thread overview]
Message-ID: <20210830084514.GI1053080@scaer> (raw)
In-Reply-To: <8ec58237-a9ee-5d95-bf88-305cb5533139@petri.us>

Jonah, All,

On 2021-08-29 20:25 -0400, Jonah Petri spake thusly:
> On 8/29/21 1:21 PM, Arnout Vandecappelle wrote:
> >On 26/08/2021 21:34, Jonah Petri wrote:
> >>  	fi ; \
> >>-	if [ ! -e $(STAGING_DIR)/lib/ld*.so.* ]; then \
> >>-		if [ -e $${ARCH_SYSROOT_DIR}/lib/ld*.so.* ]; then \
> >>-			cp -a $${ARCH_SYSROOT_DIR}/lib/ld*.so.* $(STAGING_DIR)/lib/ ; \
> >>-		fi ; \
> >>+	if [[ ! $$(find $(STAGING_DIR)/lib -name 'ld*.so.*' -print -quit) ]]; then \
> >  I was going to say: don't use [[, it's a bashism. However, we already use it in
> >helpers.mk, so I guess it's OK. It's up to whoever has a problem with it to get
> >rid of it :-)

He! Don't say such things when I'm around! ;-)

> >  Therefore, applied to next, thanks.
> 
> Thanks! I found it surprisingly hard to find a pleasing shell answer to
> "does this command succeed *and* output anything to stdout?" without
> invoking bashisms.

This is a bit less concise (two lines instead of one), but it's still
pretty easy, e.g. with a script that does not use 'set -e':

    output="$( some-command )"
    if [ ${?} -ne 0 -o -z "${output}" ]; then
        echo "Failed or output nothing"
    fi

If the script is using 'set -e', or one needs to differentiate the
reason for failure, then it is a bit more involved, but still pretty
easy and common:

    output="$( some-command )" || ret="${?}"
    if [ ${ret:-0} -ne 0 -o -z "${output}" ]; then
        echo "Exited with ${ret:-0}, or output nothing"
    fi

In our case, for Buildroot, we'd need to adapt the first solution:

    [...] ; \
    output="$$( some-command )"; \
    if [ $${?} -ne 0 -o -z "$${output}" ]; then \
        echo "Failed or output nothing"; \
    fi; \
    [...]

> I too was wary of using [[ before I saw the same usage
> lower in the file,

You caught me red-handed... I added that back in 4a5f878946c37... ;-]

> and noted that bash is a prerequisite for buildroot in
> general.

And even then, I like that we avoid bashisms when possible. But in this
case, well, it's acceptable and applied, so I won't whine (much). ;-)

> Hopefully some future dev won't curse me too much ☺ Thanks for
> applying!

Well, TIL that one can do [[ ! $(cmd) ]] to test output and return code
in one line, so... Thanks! :-)

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

  reply	other threads:[~2021-08-30  8:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-26 19:34 [Buildroot] [PATCH v3 1/1] toolchain: handle toolchains with multiple ld*.so.* files Jonah Petri
2021-08-29 17:21 ` Arnout Vandecappelle
2021-08-30  0:25   ` Jonah Petri
2021-08-30  8:45     ` Yann E. MORIN [this message]
2021-08-30  9:12       ` Arnout Vandecappelle

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=20210830084514.GI1053080@scaer \
    --to=yann.morin.1998@free.fr \
    --cc=buildroot@buildroot.org \
    --cc=giulio.benetti@benettiengineering.com \
    --cc=jonah@petri.us \
    --cc=romain.naour@gmail.com \
    --cc=thomas.de_schampheleire@nokia.com \
    --cc=thomas.petazzoni@bootlin.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox