[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #62043] The xargs -r, --no-run-if-empty Option Is Ignored When a De
From: |
Paul Eggert |
Subject: |
[bug #62043] The xargs -r, --no-run-if-empty Option Is Ignored When a Delimiter Is Passed |
Date: |
Sun, 13 Feb 2022 00:57:53 -0500 (EST) |
URL:
<https://savannah.gnu.org/bugs/?62043>
Summary: The xargs -r, --no-run-if-empty Option Is Ignored
When a Delimiter Is Passed
Project: findutils
Submitted by: eggert
Submitted on: Sat 12 Feb 2022 09:57:51 PM PST
Category: xargs
Severity: 3 - Normal
Item Group: None
Status: None
Privacy: Public
Assigned to: None
Originator Name: Kurt von Laven
Originator Email:
Open/Closed: Open
Release: None
Discussion Lock: Any
Fixed Release: None
_______________________________________________________
Details:
_I am filing this bug on behalf of Kurt von Laven, who mistakenly filed it as
Coreutils Bug 48329 <https://bugs.gnu.org/48329>. The rest of this bug report
is from Kurt._
Hello,
When the -r, --no-run-if-empty option is combined with the -d, --delimiter
or -0, --null options, the -r, --no-run-if-empty option does not
take effect. The manual describes the intended behavior of the -r,
--no-run-if-empty option: "If the standard input does not contain any
nonblanks, do not run the command. Normally, the command is run once even
if there is no input. This option is a GNU extension."
The following command correctly outputs nothing.
xargs --no-run-if-empty -I str echo str <<< ""
The following command incorrectly outputs 1 empty line.
xargs --no-run-if-empty --delimiter="\n" -I str echo str <<< ""
The following command incorrectly outputs 2 empty lines.
xargs --no-run-if-empty --null -I str echo str <<< ""
As a workaround according to this Stack Overflow answer
<https://stackoverflow.com/a/17287097/3866835>, the following commands
output nothing when the input consists only of whitespace.
[[ $input = *[![:space:]]* ]] && xargs --delimiter="\n" -I str echo str <<<
"$input"
[[ $input = *[![:space:]]* ]] || xargs --null -I str echo str <<< "$input"
Be well,
Kurt von Laven
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?62043>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [bug #62043] The xargs -r, --no-run-if-empty Option Is Ignored When a Delimiter Is Passed,
Paul Eggert <=
- [bug #62043] The xargs -r, --no-run-if-empty Option Is Ignored When a Delimiter Is Passed, Andreas Metzler, 2022/02/13
- [bug #62043] The xargs -r, --no-run-if-empty Option Is Ignored When a Delimiter Is Passed, Andreas Metzler, 2022/02/13
- [bug #62043] The xargs -r, --no-run-if-empty Option Is Ignored When a Delimiter Is Passed, Stephane Chazelas, 2022/02/23
- [bug #62043] The xargs -r, --no-run-if-empty Option Is Ignored When a Delimiter Is Passed, Andreas Metzler, 2022/02/23
- [bug #62043] The xargs -r, --no-run-if-empty Option Is Ignored When a Delimiter Is Passed, James Youngman, 2022/02/23
- [bug #62043] The xargs -r, --no-run-if-empty Option Is Ignored When a Delimiter Is Passed, Stephane Chazelas, 2022/02/23
- [bug #62043] The xargs -r, --no-run-if-empty Option Is Ignored When a Delimiter Is Passed, Andreas Metzler, 2022/02/24