linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lasse Collin <lasse.collin@tukaani.org>
To: <angel.lkml@16bits.net>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Jubin Zhong <zhongjubin@huawei.com>,
	linux-kernel@vger.kernel.org, vegard.nossum@oracle.com
Subject: Re: [PATCH 11/11] xz: Adjust arch-specific options for better kernel compression
Date: Thu, 4 Apr 2024 17:01:03 +0300	[thread overview]
Message-ID: <20240404170103.1bc382b3@kaneli> (raw)
In-Reply-To: <20240403225903.0773746d@kaneli>

On 2024-04-03 Lasse Collin wrote:
> On 2024-03-31 angel.lkml@16bits.net wrote:
> > So, in the spirit of keeping a fair amount of paranoia, and since it
> > doesn't do any harm, any such code should be failproofed to ensure
> > it can only import the expected shell variables with the right
> > format[3]:
> >
> >  eval "$($XZ --robot --version | grep
> > '^\(XZ\|LIBLZMA\)_VERSION=[0-9]*$')" || exit  
> 
> I would rather get rid of eval. I committed the following to the
> upstream repository:
> 
> XZ_VERSION=$($XZ --robot --version | sed -n 's/^XZ_VERSION=//p') ||
> exit

Both my new version and the suggested eval+grep version have error
detection issues:

  - With the eval+grep version, if there are no matches, eval gets an
    empty string as an argument in which case eval's exit status is
    zero and "exit" won't be run. Exit status from $XZ is ignored.
    XZ_VERSION won't be set or it might be inherited from the
    environment.

  - With $XZ ... | sed ..., the exit status of $XZ is ignored. sed
    will exit with 0 and thus "exit" won't be run even if $XZ fails.

Upstream I changed to this:

XZ_VERSION=$($XZ --robot --version) || exit
XZ_VERSION=$(printf '%s\n' "$XZ_VERSION" | sed -n 's/^XZ_VERSION=//p')

If output from $XZ is weird, XZ_VERSION might still become weird too.
But the way the variable is used later should at worst result in
"integer expression expected" error message.

I think the above is a good enough balance for a shell script like
this.

-- 
Lasse Collin

  reply	other threads:[~2024-04-04 14:08 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-20 18:38 [PATCH 00/11] xz: Updates to license, filters, and compression options Lasse Collin
2024-03-20 18:38 ` [PATCH 01/11] MAINTAINERS: Add XZ Embedded maintainers Lasse Collin
2024-03-20 18:38 ` [PATCH 02/11] LICENSES: Add 0BSD license text Lasse Collin
2024-03-20 18:38 ` [PATCH 03/11] xz: Switch from public domain to BSD Zero Clause License (0BSD) Lasse Collin
2024-03-20 18:38 ` [PATCH 04/11] xz: Documentation/staging/xz.rst: Revise thoroughly Lasse Collin
2024-03-20 18:38 ` [PATCH 05/11] xz: Fix comments and coding style Lasse Collin
2024-03-20 18:38 ` [PATCH 06/11] xz: Cleanup CRC32 edits from 2018 Lasse Collin
2024-03-20 18:38 ` [PATCH 07/11] xz: Optimize for-loop conditions in the BCJ decoders Lasse Collin
2024-03-20 18:38 ` [PATCH 08/11] xz: Add ARM64 BCJ filter Lasse Collin
2024-03-20 18:38 ` [PATCH 09/11] xz: Add RISC-V " Lasse Collin
2024-03-20 18:38 ` [PATCH 10/11] xz: Use 128 MiB dictionary and force single-threaded mode Lasse Collin
2024-03-20 18:38 ` [PATCH 11/11] xz: Adjust arch-specific options for better kernel compression Lasse Collin
2024-03-31  0:42   ` angel.lkml
2024-04-03 19:59     ` Lasse Collin
2024-04-04 14:01       ` Lasse Collin [this message]
2024-03-29 19:24 ` [PATCH 00/11] xz: Updates to license, filters, and compression options Jonathan Bennett
2024-03-29 19:32 ` Kees Cook
2024-03-29 20:51   ` [tech-board] " Jonathan Corbet
2024-03-30  0:37     ` Kees Cook
2024-03-30  2:56     ` [tech-board] " Andrew Morton
2024-03-30 12:48       ` Lasse Collin
2024-03-30 13:54         ` Kees Cook

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=20240404170103.1bc382b3@kaneli \
    --to=lasse.collin@tukaani.org \
    --cc=akpm@linux-foundation.org \
    --cc=angel.lkml@16bits.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vegard.nossum@oracle.com \
    --cc=zhongjubin@huawei.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;
as well as URLs for NNTP newsgroup(s).