URL: <http://savannah.gnu.org/bugs/?52137>
Summary: unexpected behaviour when combining -I and -n Project: findutils Submitted by: uli42 Submitted on: Thu 28 Sep 2017 10:37:17 AM UTC Category: xargs Severity: 3 - Normal Item Group: Wrong result Status: None Privacy: Public Assigned to: None Originator Name: Originator Email: Open/Closed: Open Discussion Lock: Any Release: 4.5.11 Fixed Release: None _______________________________________________________ Details: I see an unexpected behaviour with xargs on Ubuntu 16.04 (and also with 4.5.11 on Centos 7.4) when using -I and -n together. This is the version of xargs: $ 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. I try $ echo a b c d e f | xargs -I_ -n1 echo _xxx a b c d e fxxx -> this is expected, as the manpage states "unquoted blanks do not terminate input items" for -I But increasing -n leads to this surprising result: $ echo a b c d e f | xargs -I_ -n2 echo _xxx _xxx a b _xxx c d _xxx e f From my understanding -n2 means use 2 input items at max, and xargs is only getting one here (because of -I ignoring the spaces). So the result should be identical to the -n1 case. Also -I does not seem to have an effect here, nothing is replaced. Playing around shows even more unexpected stuff: $ echo a b c d e f | xargs -n2 -I_ echo _xxx a b c d e fxxx Obviously the position of -n does matter here, but I cannot find the manpage mentioning that. Now, adding spaces as delimiters it gets even weirder: $ echo a b c d e f | xargs -n1 -d" " -I_ echo _xxx axxx bxxx cxxx dxxx exxx f xxx That one looks good at first sight, but the manpage refers to -d as a single character, so it does not include \n anymore. But the line break that echo appends is treated as a delimiter, too. Now, increasing -n again does not change the output. But it should: $ echo a b c d e f | xargs -n2 -d" " -I_ echo _xxx axxx bxxx cxxx dxxx exxx f xxx So it looks to me that handling -I and -n in the same command line is broken somehow. _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?52137> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/