Latest grep (3.8) warns about unneeded backslashes when building kdump initrd [1],
kdump: Rebuilding /boot/initramfs-6.0.0-0.rc5.a335366bad13.40.test.fc38.aarch64kdump.img grep: warning: stray \ before - grep: warning: stray \ before - grep: warning: stray \ before - grep: warning: stray \ before - grep: warning: stray \ before -
Use the -- argument (don't treat the following - as options) to get rid of these warnings.
[1] https://s3.us-east-1.amazonaws.com/arr-cki-prod-datawarehouse-public/datawar...
Reported-by: Baoquan He bhe@redhat.com Signed-off-by: Coiby Xu coxu@redhat.com --- kdump-lib-initramfs.sh | 4 ++-- kdumpctl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 84e6bf75..73a464d5 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -58,13 +58,13 @@ is_fs_type_nfs() # If $1 contains dracut_args "--mount", return <filesystem type> get_dracut_args_fstype() { - echo $1 | grep "--mount" | sed "s/.*--mount .(.*)/\1/" | cut -d' ' -f3 + echo $1 | grep -- "--mount" | sed "s/.*--mount .(.*)/\1/" | cut -d' ' -f3 }
# If $1 contains dracut_args "--mount", return <device> get_dracut_args_target() { - echo $1 | grep "--mount" | sed "s/.*--mount .(.*)/\1/" | cut -d' ' -f1 + echo $1 | grep -- "--mount" | sed "s/.*--mount .(.*)/\1/" | cut -d' ' -f1 }
get_save_path() diff --git a/kdumpctl b/kdumpctl index 0e37d36e..3503befe 100755 --- a/kdumpctl +++ b/kdumpctl @@ -224,7 +224,7 @@ parse_config() case "$config_opt" in dracut_args) if [[ $config_val == *--mount* ]]; then - if [[ $(echo "$config_val" | grep -o "--mount" | wc -l) -ne 1 ]]; then + if [[ $(echo "$config_val" | grep -o -- "--mount" | wc -l) -ne 1 ]]; then derror 'Multiple mount targets specified in one "dracut_args".' return 1 fi @@ -506,7 +506,7 @@ check_fs_modified()
# if --mount argument present then match old and new target, mount # point and file system. If any of them mismatches then rebuild - if echo "$_dracut_args" | grep -q "--mount"; then + if echo "$_dracut_args" | grep -q -- "--mount"; then # shellcheck disable=SC2046 set -- $(echo "$_dracut_args" | awk -F "--mount '" '{print $2}' | cut -d' ' -f1,2,3) _old_dev=$1
Hi Coiby,
this one doesn't seem to be merged yet.
Looks good. Although for the first two you could drop grep and use sed -n instead. But that can be done in an other patch.
Reviewed-by: Philipp Rudo prudo@redhat.com
On Tue, 20 Sep 2022 17:32:27 +0800 Coiby Xu coxu@redhat.com wrote:
Latest grep (3.8) warns about unneeded backslashes when building kdump initrd [1],
kdump: Rebuilding /boot/initramfs-6.0.0-0.rc5.a335366bad13.40.test.fc38.aarch64kdump.img grep: warning: stray \ before - grep: warning: stray \ before - grep: warning: stray \ before - grep: warning: stray \ before - grep: warning: stray \ before -Use the -- argument (don't treat the following - as options) to get rid of these warnings.
[1] https://s3.us-east-1.amazonaws.com/arr-cki-prod-datawarehouse-public/datawar...
Reported-by: Baoquan He bhe@redhat.com Signed-off-by: Coiby Xu coxu@redhat.com
kdump-lib-initramfs.sh | 4 ++-- kdumpctl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 84e6bf75..73a464d5 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -58,13 +58,13 @@ is_fs_type_nfs() # If $1 contains dracut_args "--mount", return <filesystem type> get_dracut_args_fstype() {
- echo $1 | grep "--mount" | sed "s/.*--mount .(.*)/\1/" | cut -d' ' -f3
- echo $1 | grep -- "--mount" | sed "s/.*--mount .(.*)/\1/" | cut -d' ' -f3
}
# If $1 contains dracut_args "--mount", return <device> get_dracut_args_target() {
- echo $1 | grep "--mount" | sed "s/.*--mount .(.*)/\1/" | cut -d' ' -f1
- echo $1 | grep -- "--mount" | sed "s/.*--mount .(.*)/\1/" | cut -d' ' -f1
}
get_save_path() diff --git a/kdumpctl b/kdumpctl index 0e37d36e..3503befe 100755 --- a/kdumpctl +++ b/kdumpctl @@ -224,7 +224,7 @@ parse_config() case "$config_opt" in dracut_args) if [[ $config_val == *--mount* ]]; then
if [[ $(echo "$config_val" | grep -o "\-\-mount" | wc -l) -ne 1 ]]; then
if [[ $(echo "$config_val" | grep -o -- "--mount" | wc -l) -ne 1 ]]; then derror 'Multiple mount targets specified in one "dracut_args".' return 1 fi@@ -506,7 +506,7 @@ check_fs_modified()
# if --mount argument present then match old and new target, mount # point and file system. If any of them mismatches then rebuild
- if echo "$_dracut_args" | grep -q "--mount"; then
- if echo "$_dracut_args" | grep -q -- "--mount"; then # shellcheck disable=SC2046 set -- $(echo "$_dracut_args" | awk -F "--mount '" '{print $2}' | cut -d' ' -f1,2,3) _old_dev=$1
Latest grep (3.8) warnings about unneeded backslashes when building kdump initrd [1], kdump: Rebuilding /boot/initramfs-6.0.0-0.rc5.a335366bad13.40.test.fc38.aarch64kdump.img grep: warning: stray \ before - grep: warning: stray \ before - grep: warning: stray \ before - grep: warning: stray \ before - grep: warning: stray \ before -
Some warnings can be avoided by using "sed -n" to remove grep and the others can use the -- argument.
[1] https://s3.us-east-1.amazonaws.com/arr-cki-prod-datawarehouse-public/datawar...
Reported-by: Baoquan He bhe@redhat.com Signed-off-by: Coiby Xu coxu@redhat.com Suggested-by: Philipp Rudo prudo@redhat.com Reviewed-by: Philipp Rudo prudo@redhat.com --- v2 - use "sed -n" to avoid grep [Philipp] - quote the variable to avoid shellcheck warnings --- kdump-lib-initramfs.sh | 4 ++-- kdumpctl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index e982b14e..52dfcb4d 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -63,13 +63,13 @@ is_fs_type_virtiofs() # If $1 contains dracut_args "--mount", return <filesystem type> get_dracut_args_fstype() { - echo $1 | grep "--mount" | sed "s/.*--mount .(.*)/\1/" | cut -d' ' -f3 + echo "$1" | sed -n "s/.*--mount .(.*)/\1/p" | cut -d' ' -f3 }
# If $1 contains dracut_args "--mount", return <device> get_dracut_args_target() { - echo $1 | grep "--mount" | sed "s/.*--mount .(.*)/\1/" | cut -d' ' -f1 + echo "$1" | sed -n "s/.*--mount .(.*)/\1/p" | cut -d' ' -f1 }
get_save_path() diff --git a/kdumpctl b/kdumpctl index 7f82f4fa..8ff4cb06 100755 --- a/kdumpctl +++ b/kdumpctl @@ -224,7 +224,7 @@ parse_config() case "$config_opt" in dracut_args) if [[ $config_val == *--mount* ]]; then - if [[ $(echo "$config_val" | grep -o "--mount" | wc -l) -ne 1 ]]; then + if [[ $(echo "$config_val" | grep -o -- "--mount" | wc -l) -ne 1 ]]; then derror 'Multiple mount targets specified in one "dracut_args".' return 1 fi @@ -506,7 +506,7 @@ check_fs_modified()
# if --mount argument present then match old and new target, mount # point and file system. If any of them mismatches then rebuild - if echo "$_dracut_args" | grep -q "--mount"; then + if echo "$_dracut_args" | grep -q -- "--mount"; then # shellcheck disable=SC2046 set -- $(echo "$_dracut_args" | awk -F "--mount '" '{print $2}' | cut -d' ' -f1,2,3) _old_dev=$1
Hi Coiby,
Looks good.
Thanks! Philipp
On Wed, 26 Oct 2022 14:12:32 +0800 Coiby Xu coxu@redhat.com wrote:
Latest grep (3.8) warnings about unneeded backslashes when building kdump initrd [1], kdump: Rebuilding /boot/initramfs-6.0.0-0.rc5.a335366bad13.40.test.fc38.aarch64kdump.img grep: warning: stray \ before - grep: warning: stray \ before - grep: warning: stray \ before - grep: warning: stray \ before - grep: warning: stray \ before -
Some warnings can be avoided by using "sed -n" to remove grep and the others can use the -- argument.
[1] https://s3.us-east-1.amazonaws.com/arr-cki-prod-datawarehouse-public/datawar...
Reported-by: Baoquan He bhe@redhat.com Signed-off-by: Coiby Xu coxu@redhat.com Suggested-by: Philipp Rudo prudo@redhat.com Reviewed-by: Philipp Rudo prudo@redhat.com
v2
- use "sed -n" to avoid grep [Philipp]
- quote the variable to avoid shellcheck warnings
kdump-lib-initramfs.sh | 4 ++-- kdumpctl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index e982b14e..52dfcb4d 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -63,13 +63,13 @@ is_fs_type_virtiofs() # If $1 contains dracut_args "--mount", return <filesystem type> get_dracut_args_fstype() {
- echo $1 | grep "--mount" | sed "s/.*--mount .(.*)/\1/" | cut -d' ' -f3
- echo "$1" | sed -n "s/.*--mount .(.*)/\1/p" | cut -d' ' -f3
}
# If $1 contains dracut_args "--mount", return <device> get_dracut_args_target() {
- echo $1 | grep "--mount" | sed "s/.*--mount .(.*)/\1/" | cut -d' ' -f1
- echo "$1" | sed -n "s/.*--mount .(.*)/\1/p" | cut -d' ' -f1
}
get_save_path() diff --git a/kdumpctl b/kdumpctl index 7f82f4fa..8ff4cb06 100755 --- a/kdumpctl +++ b/kdumpctl @@ -224,7 +224,7 @@ parse_config() case "$config_opt" in dracut_args) if [[ $config_val == *--mount* ]]; then
if [[ $(echo "$config_val" | grep -o "\-\-mount" | wc -l) -ne 1 ]]; then
if [[ $(echo "$config_val" | grep -o -- "--mount" | wc -l) -ne 1 ]]; then derror 'Multiple mount targets specified in one "dracut_args".' return 1 fi@@ -506,7 +506,7 @@ check_fs_modified()
# if --mount argument present then match old and new target, mount # point and file system. If any of them mismatches then rebuild
- if echo "$_dracut_args" | grep -q "--mount"; then
- if echo "$_dracut_args" | grep -q -- "--mount"; then # shellcheck disable=SC2046 set -- $(echo "$_dracut_args" | awk -F "--mount '" '{print $2}' | cut -d' ' -f1,2,3) _old_dev=$1
Hi Philipp,
On Tue, Oct 25, 2022 at 04:09:57PM +0200, Philipp Rudo wrote:
Hi Coiby,
this one doesn't seem to be merged yet.
Looks good. Although for the first two you could drop grep and use sed -n instead. But that can be done in an other patch.
Thanks for proposing a smarter fix! I've sent&merged v2 following your suggestion.
Reviewed-by: Philipp Rudo prudo@redhat.com
And thanks for the review!
On Tue, 20 Sep 2022 17:32:27 +0800 Coiby Xu coxu@redhat.com wrote:
Latest grep (3.8) warns about unneeded backslashes when building kdump initrd [1],
kdump: Rebuilding /boot/initramfs-6.0.0-0.rc5.a335366bad13.40.test.fc38.aarch64kdump.img grep: warning: stray \ before - grep: warning: stray \ before - grep: warning: stray \ before - grep: warning: stray \ before - grep: warning: stray \ before -Use the -- argument (don't treat the following - as options) to get rid of these warnings.
[1] https://s3.us-east-1.amazonaws.com/arr-cki-prod-datawarehouse-public/datawar...
Reported-by: Baoquan He bhe@redhat.com Signed-off-by: Coiby Xu coxu@redhat.com
kdump-lib-initramfs.sh | 4 ++-- kdumpctl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 84e6bf75..73a464d5 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -58,13 +58,13 @@ is_fs_type_nfs() # If $1 contains dracut_args "--mount", return <filesystem type> get_dracut_args_fstype() {
- echo $1 | grep "--mount" | sed "s/.*--mount .(.*)/\1/" | cut -d' ' -f3
- echo $1 | grep -- "--mount" | sed "s/.*--mount .(.*)/\1/" | cut -d' ' -f3
}
# If $1 contains dracut_args "--mount", return <device> get_dracut_args_target() {
- echo $1 | grep "--mount" | sed "s/.*--mount .(.*)/\1/" | cut -d' ' -f1
- echo $1 | grep -- "--mount" | sed "s/.*--mount .(.*)/\1/" | cut -d' ' -f1
}
get_save_path() diff --git a/kdumpctl b/kdumpctl index 0e37d36e..3503befe 100755 --- a/kdumpctl +++ b/kdumpctl @@ -224,7 +224,7 @@ parse_config() case "$config_opt" in dracut_args) if [[ $config_val == *--mount* ]]; then
if [[ $(echo "$config_val" | grep -o "\-\-mount" | wc -l) -ne 1 ]]; then
if [[ $(echo "$config_val" | grep -o -- "--mount" | wc -l) -ne 1 ]]; then derror 'Multiple mount targets specified in one "dracut_args".' return 1 fi@@ -506,7 +506,7 @@ check_fs_modified()
# if --mount argument present then match old and new target, mount # point and file system. If any of them mismatches then rebuild
- if echo "$_dracut_args" | grep -q "--mount"; then
- if echo "$_dracut_args" | grep -q -- "--mount"; then # shellcheck disable=SC2046 set -- $(echo "$_dracut_args" | awk -F "--mount '" '{print $2}' | cut -d' ' -f1,2,3) _old_dev=$1