bugfindutils - Bugs: bug #58149, Whitespace parsing differs with...

 
 

bug #58149: Whitespace parsing differs with and without -i

Submitter:  None
Submitted:  Thu 09 Apr 2020 05:55:59 PM UTC
   
 
Category:  xargs Severity:  3 - Normal
Item Group:  Wrong result Status:  Fixed
Privacy:  Public Assigned to:  berny
Originator Name:  Ryan Moore Originator Email:  -email is unavailable-
Open/Closed:  Closed Release:  4.7.0
Fixed Release:  4.8.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 05 Jan 2021 04:20:04 PM UTC, comment #3: 
Bernhard Voelker <berny>
Group administrator
Fri 10 Apr 2020 06:26:48 PM UTC, comment #2: 

comment #1:

> That is documented behavior.


I see that in `man`, but not with `--help` which doesn't hint to that critical second part:


  -I R                         same as --replace=R
  -i, --replace[=R]            replace R in INITIAL-ARGS with names read
                                 from standard input; if R is unspecified,
                                 assume {}


Can that be added on to the `--help` output? Something like "Also changes delimiter from any whitespace to only newline character".

Anonymous
Fri 10 Apr 2020 04:59:53 AM UTC, comment #1: 

That is documented behavior.

-i[replace-str], --replace[=replace-str]
              This option is a synonym for  -Ireplace-str  if replace-str  is specified. [...]

-I replace-str
              Replace occurrences of replace-str in the initial-arguments with names read from standard input.  Also, unquoted blanks do not terminate input  items; instead the separator is the newline character. [...]

Andreas Metzler <ametzler>
Thu 09 Apr 2020 05:55:59 PM UTC, original submission:  

I would expect this to use -n1 to separate the whitespace-delimited parameters "a" and "b" and "c" to print 3 separate lines:


root@rmoore:~# echo "a b c" | xargs -n1 -i{} echo foo {}
foo a b c


If I manually specify a space as the delimiter, it works as expected (and gives an extra CR with the last line, since it's now "c\n"):


root@rmoore:~# echo "a b c" | xargs -d\  -n1 -i{} echo foo {}
foo a
foo b
foo c



If I run without -I{} as a substitution, it works as expected (and prints {} explicitly):

root@rmoore:~# echo "a b c" | xargs -n1 echo foo {}
foo {} a
foo {} b
foo {} c



Version info, from Ubuntu 16.04 (also confirmed on 18.04):

root@rmoore:~# xargs --version
xargs (GNU findutils) 4.7.0-git
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Eric B. Decker, James Youngman, and Kevin Dalley.


Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by berny (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-01-09 berny Open/ClosedOpen Closed
        Fixed ReleaseNone 4.8.0
    2021-01-05 berny StatusNone Fixed
        Assigned toNone berny

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code