All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Theodore Ts'o <tytso@mit.edu>
Cc: fstests@vger.kernel.org
Subject: Re: [PATCH] common/filter: add _filter_bash()
Date: Wed, 15 Dec 2021 16:54:19 -0800	[thread overview]
Message-ID: <YbqOO74Lfer5h33Y@sol.localdomain> (raw)
In-Reply-To: <20211214170438.16164-1-tytso@mit.edu>

Hi Ted,

On Tue, Dec 14, 2021 at 12:04:38PM -0500, Theodore Ts'o wrote:
> This is needed to account for bash 5.1 adding line number annotation
> when a command like "bash -c /etc/passwd" fails, e.g., with
> 
>      bash: line 1: /etc/passwd: Permission denied
> 
> instead of:
> 
>      bash: /etc/passwd: Permission denied
> 
> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
> ---
>  common/filter     | 11 +++++++++++
>  tests/generic/572 | 33 +++++++++++++++++++--------------
>  2 files changed, 30 insertions(+), 14 deletions(-)
> 
> diff --git a/common/filter b/common/filter
> index 2efbbd99..4b250e8b 100644
> --- a/common/filter
> +++ b/common/filter
> @@ -661,5 +661,16 @@ _filter_quota_report()
>  		s|^(.*?) (\d+) (\d+) (\d+)|$1 @{[$2 * 1024 /'$bsize']} @{[$3 * 1024 /'$bsize']} @{[$4 * 1024 /'$bsize']}|'
>  }
>  
> +#
> +# Bash 5.1+ adds "line 1: " when printing an error running an executable
> +# for example, "bash -c /etc/passwd" will result in the error
> +# "bash: line 1: /etc/passwd: Permission denied" where as earlier
> +# versions of bash will omit the "line 1: " annotation.
> +#
> +_filter_bash()
> +{
> +	sed -e "s/^bash: line 1: /bash: /"
> +}
> +

Doesn't this happen with any shell command passed to -c, not just commands that
run an executable?  In the commands below which are causing the problem, it is
actually the 'echo' built-in being used, not an executable.

> -bash -c "echo >> $fsv_file" |& _filter_scratch
> +bash -c "echo >> $fsv_file" |& filter_output
>  echo "* bash >, should be O_WRONLY|O_CREAT|O_TRUNC"
> -bash -c "echo > $fsv_file" |& _filter_scratch
> +bash -c "echo > $fsv_file" |& filter_output

Otherwise this patch looks good, thanks!

- Eric

  reply	other threads:[~2021-12-16  0:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-14 17:04 [PATCH] common/filter: add _filter_bash() Theodore Ts'o
2021-12-16  0:54 ` Eric Biggers [this message]
2021-12-18 17:10   ` Theodore Ts'o
2021-12-19  2:34     ` Eric Biggers
2021-12-19  4:16       ` [PATCH -v2] " Theodore Ts'o
2021-12-19  5:24         ` Eric Biggers
  -- strict thread matches above, loose matches on Subject: below --
2021-08-30 11:41 [PATCH] " Theodore Ts'o
2021-08-31 23:53 ` Dave Chinner

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=YbqOO74Lfer5h33Y@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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.