common/rc: handle option with argument in _require_xfs_io_command()

Fix _require_xfs_io_command() to handle options that take arguments when
the argument is shown in the help text.  E.g., it didn't work to run:

	_require_xfs_io_command "add_enckey" "-k"

because the relevant line of the help text is:

	-k KEY_ID -- ID of fscrypt-provisioning key containing the raw key

... but the grep command only matched "-k --", not "-k KEY_ID --".

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
This commit is contained in:
Eric Biggers
2020-02-03 10:18:53 -08:00
committed by Eryu Guan
parent e7aab38355
commit 231f246501
+1 -1
View File
@@ -2248,7 +2248,7 @@ _require_xfs_io_command()
[ -n "$param" ] || return
if [ -z "$param_checked" ]; then
$XFS_IO_PROG -c "help $command" | grep -q "^ $param --" || \
$XFS_IO_PROG -c "help $command" | grep -E -q "^ $param ([a-zA-Z_]+ )?--" || \
_notrun "xfs_io $command doesn't support $param"
else
# xfs_io could result in "command %c not supported" if it was