Re: [PATCH] common/filter: add _filter_bash()

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



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@xxxxxxx>
> ---
>  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



[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux