Re: [PATCH] btrfs: use full subcommand name at _btrfs_get_subvolid()

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



On Fri, 22 Sep 2023 12:45:01 +0100, fdmanana@xxxxxxxxxx wrote:

> From: Filipe Manana <fdmanana@xxxxxxxx>
> 
> Avoid using the shortcut "sub" for the "subvolume" command, as this is the
> standard practice because such shortcuts are not guaranteed to exist in
> every btrfs-progs release (they may come and go). Also make the variables
> local.

Hmm, having them come and go would likely break quite a few user
scripts...

> 
> Signed-off-by: Filipe Manana <fdmanana@xxxxxxxx>
> ---
>  common/btrfs | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/common/btrfs b/common/btrfs
> index c9903a41..62cee209 100644
> --- a/common/btrfs
> +++ b/common/btrfs
> @@ -6,10 +6,10 @@
>  
>  _btrfs_get_subvolid()
>  {
> -	mnt=$1
> -	name=$2
> +	local mnt=$1
> +	local name=$2
>  
> -	$BTRFS_UTIL_PROG sub list $mnt | grep -E "\s$name$" | $AWK_PROG '{ print $2 }'
> +	$BTRFS_UTIL_PROG subvolume list $mnt | grep -E "\s$name$" | $AWK_PROG '{ print $2 }'

My grep+awk OCD would say that this should be:
$BTRFS_UTIL_PROG subvolume list $mnt | $AWK_PROG -v name="$name" '$9 == name { print $2 }'

Looks fine as is though.
Reviewed-by: David Disseldorp <ddiss@xxxxxxx>




[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