fstests.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Theodore Ts'o <tytso@mit.edu>
Cc: fstests@vger.kernel.org
Subject: Re: [PATCH] common/filter: add _filter_bash()
Date: Wed, 1 Sep 2021 09:53:20 +1000	[thread overview]
Message-ID: <20210831235320.GK2566745@dread.disaster.area> (raw)
In-Reply-To: <20210830114156.1106699-1-tytso@mit.edu>

On Mon, Aug 30, 2021 at 07:41:56AM -0400, 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 denid
> 
> instead of:
> 
>      bash: /etc/passwd: Permission denid
> 
> 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: /"
> +}

If this remains, it needs a much more specific name. "filter_bash"
could mean just about anything...

>  # make sure this script returns success
>  /bin/true
> diff --git a/tests/generic/572 b/tests/generic/572
> index f131c7ed..cded9ac6 100755
> --- a/tests/generic/572
> +++ b/tests/generic/572
> @@ -36,6 +36,11 @@ _scratch_mount
>  fsv_orig_file=$SCRATCH_MNT/file
>  fsv_file=$SCRATCH_MNT/file.fsv
>  
> +filter_output()
> +{
> +    _filter_bash | _filter_scratch
> +}

But given that this is only needed by a single test, why create
a generic "_filter_bash" function? Surely this could simply be:

filter_output()
{
    sed -e "s/^bash: line 1: /bash: /" | _filter_scratch
}

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

  reply	other threads:[~2021-08-31 23:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-30 11:41 [PATCH] common/filter: add _filter_bash() Theodore Ts'o
2021-08-31 23:53 ` Dave Chinner [this message]
2021-12-14 17:04 Theodore Ts'o
2021-12-16  0:54 ` Eric Biggers
2021-12-18 17:10   ` Theodore Ts'o
2021-12-19  2:34     ` Eric Biggers

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=20210831235320.GK2566745@dread.disaster.area \
    --to=david@fromorbit.com \
    --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 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).