Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Arnout Vandecappelle <arnout@mind.be>
To: "Yann E. MORIN" <yann.morin.1998@free.fr>, Jonah Petri <jonah@petri.us>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Giulio Benetti <giulio.benetti@benettiengineering.com>,
	Romain Naour <romain.naour@gmail.com>,
	Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>,
	buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH v3 1/1] toolchain: handle toolchains with multiple ld*.so.* files
Date: Mon, 30 Aug 2021 11:12:07 +0200	[thread overview]
Message-ID: <86237c6f-e02e-d47e-84e8-00e18ac6e02c@mind.be> (raw)
In-Reply-To: <20210830084514.GI1053080@scaer>



On 30/08/2021 10:45, Yann E. MORIN wrote:
> 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 you want concise (and covering all set -e cases AFAICS):

if ! output="$(some-command)" || [ -z "$output" ]; then ...

(as always: untested, YMMV)

 Regards,
 Arnout

> 
> 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.
> 
_______________________________________________
buildroot mailing list
buildroot@busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

      reply	other threads:[~2021-08-30  9:12 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
2021-08-30  9:12       ` Arnout Vandecappelle [this message]

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=86237c6f-e02e-d47e-84e8-00e18ac6e02c@mind.be \
    --to=arnout@mind.be \
    --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 \
    --cc=yann.morin.1998@free.fr \
    /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