GNU bug report logs - #28469
xargs arguments are not passed to grep

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: grep; Reported by: Sergiu Bordei <sergiu.bordei@HIDDEN>; Keywords: notabug; Done: Paul Eggert <eggert@HIDDEN>; Maintainer for grep is bug-grep@HIDDEN.
bug closed, send any further explanations to 28469 <at> debbugs.gnu.org and Sergiu Bordei <sergiu.bordei@HIDDEN> Request was from Paul Eggert <eggert@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Added tag(s) notabug. Request was from Paul Eggert <eggert@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 15 Sep 2017 16:34:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 15 12:34:39 2017
Received: from localhost ([127.0.0.1]:43067 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1dstZf-0007a8-8V
	for submit <at> debbugs.gnu.org; Fri, 15 Sep 2017 12:34:39 -0400
Received: from eggs.gnu.org ([208.118.235.92]:51555)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <pj@HIDDEN>) id 1dstZe-0007Zv-3r
 for submit <at> debbugs.gnu.org; Fri, 15 Sep 2017 12:34:38 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <pj@HIDDEN>) id 1dstZX-0004Zy-VC
 for submit <at> debbugs.gnu.org; Fri, 15 Sep 2017 12:34:32 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,T_DKIM_INVALID,
 URIBL_BLOCKED autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:37859)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <pj@HIDDEN>) id 1dstZX-0004Zu-SG
 for submit <at> debbugs.gnu.org; Fri, 15 Sep 2017 12:34:31 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:42516)
 by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <pj@HIDDEN>)
 id 1dstZW-0002xA-PV
 for bug-grep@HIDDEN; Fri, 15 Sep 2017 12:34:31 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <pj@HIDDEN>) id 1dstZU-0004Yg-6f
 for bug-grep@HIDDEN; Fri, 15 Sep 2017 12:34:30 -0400
Received: from out4-smtp.messagingengine.com ([66.111.4.28]:38207)
 by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <pj@HIDDEN>) id 1dstZU-0004YG-0a
 for bug-grep@HIDDEN; Fri, 15 Sep 2017 12:34:28 -0400
Received: from compute1.internal (compute1.nyi.internal [10.202.2.41])
 by mailout.nyi.internal (Postfix) with ESMTP id B24EB20C79;
 Fri, 15 Sep 2017 12:34:26 -0400 (EDT)
Received: from web2 ([10.202.2.212])
 by compute1.internal (MEProxy); Fri, 15 Sep 2017 12:34:26 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=content-transfer-encoding:content-type
 :date:from:in-reply-to:message-id:mime-version:references
 :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=iOGB7L
 egrIjfkUakRWbJ3aMarthAn/vUKRngwh9lyms=; b=bcS6L5zmzFCDbAn2b/jvLs
 x5701E+XxZr6B8VkeVju/77tGL8ZxgVhYlJjsDa15fB5im/BFzfwIN4F5kxphGWF
 OhWIU4gu61osuGfz1xMTF1j1BsvhMth3m22VXpNZAH3p5wtVF61Zo6e1qZAcBW67
 E92SZglwXP0YAhbnRfvlkAQibQDw0Se38RpKPmse2e0LFju2tQEpc0sQ1uqk58Xw
 5YNt4J94rWldCkYLXEvCO1zib2wo/Vbf0dRJuqXsAvlJTN2Kan45cRhVZ1JZA2Kw
 tMUMv3oMJ2OZ/3bhKab2lQEMjkgKobbOLk/ljFAsTYSRQZ/ku+aJOlKwgmJf2UCw
 ==
X-ME-Sender: <xms:EgG8WaEAUu--132Q38Ck4nhnTWEKCByEFHmSQQS9I2Eb9G_NJ4Q96Q>
Received: by mailuser.nyi.internal (Postfix, from userid 99)
 id 6BBB26264D; Fri, 15 Sep 2017 12:34:26 -0400 (EDT)
Message-Id: <1505493266.301725.1107434376.75200589@HIDDEN>
From: Paul Jackson <pj@HIDDEN>
To: bug-grep@HIDDEN, sergiu.bordei@HIDDEN
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="utf-8"
X-Mailer: MessagingEngine.com Webmail Interface - ajax-64b08692
References: <CAHdJQNUhKq96VE57aQTGFqrYYpHQC_uH80ZaVNkpa5R8HwaBDQ@HIDDEN>
In-Reply-To: <CAHdJQNUhKq96VE57aQTGFqrYYpHQC_uH80ZaVNkpa5R8HwaBDQ@HIDDEN>
Date: Fri, 15 Sep 2017 11:34:26 -0500
Subject: Re: bug#28469: xargs arguments are not passed to grep
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [fuzzy]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.4 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.4 (----)

Sergiu wrote:
>> please find an error detected when is used a combination of "xargs" and
>> "grep", arguments {} are not substituted in grep construction:

I believe that all your examples, both expected (count of "1" resulting)
and apparently unexpected (outputs of "i i 0") are working as expected.

I am guessing (am I right?) that you were expecting outputs of "i i 1"
or some such from your last six more complex examples using xargs,
however that "echo inga | grep -c $a" is working on an $a value that
is still inside the $( ... ) or ` ... ` command substitution, and thus equal
to '{}', with $a not yet set to "i" by the final execution of the xargs
invocation of the output from that command substitution.

-- 
                Paul Jackson
                pj@HIDDEN




Information forwarded to bug-grep@HIDDEN:
bug#28469; Package grep. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 15 Sep 2017 15:38:04 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 15 11:38:04 2017
Received: from localhost ([127.0.0.1]:43024 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1dssgt-0006G0-Ki
	for submit <at> debbugs.gnu.org; Fri, 15 Sep 2017 11:38:03 -0400
Received: from eggs.gnu.org ([208.118.235.92]:41396)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sergiu.bordei@HIDDEN>) id 1dsnE6-0002hW-Fu
 for submit <at> debbugs.gnu.org; Fri, 15 Sep 2017 05:47:58 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <sergiu.bordei@HIDDEN>) id 1dsnE0-0001ie-Ch
 for submit <at> debbugs.gnu.org; Fri, 15 Sep 2017 05:47:53 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
 HTML_MESSAGE,T_DKIM_INVALID autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:59688)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <sergiu.bordei@HIDDEN>)
 id 1dsnE0-0001iS-8r
 for submit <at> debbugs.gnu.org; Fri, 15 Sep 2017 05:47:52 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:60589)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <sergiu.bordei@HIDDEN>) id 1dsnDy-0002yq-VF
 for bug-grep@HIDDEN; Fri, 15 Sep 2017 05:47:51 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <sergiu.bordei@HIDDEN>) id 1dsnDy-0001hf-31
 for bug-grep@HIDDEN; Fri, 15 Sep 2017 05:47:51 -0400
Received: from mail-wm0-x22e.google.com ([2a00:1450:400c:c09::22e]:43903)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <sergiu.bordei@HIDDEN>)
 id 1dsnDx-0001gn-Tc
 for bug-grep@HIDDEN; Fri, 15 Sep 2017 05:47:50 -0400
Received: by mail-wm0-x22e.google.com with SMTP id a137so1964754wma.0
 for <bug-grep@HIDDEN>; Fri, 15 Sep 2017 02:47:48 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:from:date:message-id:subject:to;
 bh=Mjt8sOQvm+aCuR7R6UICqeMg0IBSzc+AYdOPaaK4oAE=;
 b=oYhd+/X4crGKOzqSEyUcsboCXV41KRU70Gi3OixhVgo3nTC/u2u3OOYZAz5CM/2V/5
 YhLSo4d0hVsH0A4PXS/X4c37ZM6+rKSStyRZB7cu0FzEYtNNEMxMS2jCQH+3nlrEUs7J
 ijeem1IJVeIv5mlDYOF40KO00BWKedXDjimz4YaTlK8OfKiqzKEohV1HRcHQjVQthJwR
 4FxUJmKlPdTlgqmtkNzn3nCjgcrbhDjNQeoGOCXcqOQMwBbkA3dMMHK7XYiAdHswD19q
 6eeVdey8lhSAiH9GZPHeyW4pCxG2lY6paBNPCUzJsVplR2RHuQ8zVKZt5HJVKWVyFa1a
 4OqQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
 bh=Mjt8sOQvm+aCuR7R6UICqeMg0IBSzc+AYdOPaaK4oAE=;
 b=idXq0DmGxLQimCmJD1+FHkwX29d7gQZ3j9FEvCSV5e/PXDF0og//0hq6gDkMlnF9vc
 8ffqQseZyKcdzIpjYlJB2KegYLC+DfZdcfoT4yZip1s8fpS9RWhKe/4vk8AQ33RCV1/i
 E0ndiGaf3JGvOaKrYAUUEv5zkLPdi5QWXL2vCz/qMY9u/vVYSmR6+IgJNp2SI6ptQu+e
 1bNHo0x/B734dgYvGeN+dDGGgPNuDCmoyquTPRU3XmWlQeG2drctGFMNpWhnOwZ7UNjm
 OsOcX2yJpNIvAkfG72B/fclVSKrCMag/Q0nWf2u39RCInAKVbL2aHVNsurjtriI+4UIY
 fa8g==
X-Gm-Message-State: AHPjjUi66LYPGNYvUEnbZ5CosNPrSlvpAhpTrpBcsaDgqppyTXmes1E3
 fwkA/L7VLcNK+M57F9rgN1nBDxxWb1fbNPuHAMAlog==
X-Google-Smtp-Source: ADKCNb4VsinqXlSnGpYLN+d/uZmNbMEhqXn2rnm5YnCjUKKYrtjJVDXLZjWTkuM7rIClGSw5w/NPGkBHIO2DeKIBuTg=
X-Received: by 10.80.213.211 with SMTP id g19mr16472705edj.277.1505468867183; 
 Fri, 15 Sep 2017 02:47:47 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.80.159.168 with HTTP; Fri, 15 Sep 2017 02:47:46 -0700 (PDT)
From: Sergiu Bordei <sergiu.bordei@HIDDEN>
Date: Fri, 15 Sep 2017 11:47:46 +0200
Message-ID: <CAHdJQNUhKq96VE57aQTGFqrYYpHQC_uH80ZaVNkpa5R8HwaBDQ@HIDDEN>
Subject: xargs arguments are not passed to grep
To: bug-grep@HIDDEN
Content-Type: multipart/alternative; boundary="94eb2c1af5100c89f405593749af"
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.0 (----)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Fri, 15 Sep 2017 11:38:00 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.0 (----)

--94eb2c1af5100c89f405593749af
Content-Type: text/plain; charset="UTF-8"

Hello,

please find an error detected when is used a combination of "xargs" and
"grep", arguments {} are not substituted in grep construction:
expected results:
echo "inga"|grep -c "i"
1
user@box1:~$ a="i"; echo `echo "inga"|grep -c $a`
1

but was necessary tu use it in combination with xargs:

user@box1:~$ echo "i" | xargs -I{} echo $(echo {} ;a=$(echo {}) ; echo $a ;
echo "inga"|grep -c $a)
i i 0
user@box1:~$ echo "i" | xargs -I{} echo $(echo {} ;a=`echo {}` ; echo $a ;
echo "inga"|grep -c $a)
i i 0
user@box1:~$ echo "i" | xargs -I{} echo $(echo {} ;a={} ; echo $a ; echo
"inga"|grep -c $a)
i i 0
user@box1:~$ echo "i" | xargs  -I{} echo `echo {} ;a={} ; echo $a ; echo
"inga"|grep -c $a`
i i 0
user@box1:~$ echo "i" | xargs -I{} echo `echo {} ;a={} ; echo $a ; echo
"inga"|grep -c $a`
i i 0
user@box1:~$ echo "i" | xargs -I{} echo `echo {} ;a={} ; echo $a ; echo
"inga"|grep -c $a`
i i 0



Thanks,
Sergiu Bordei

--94eb2c1af5100c89f405593749af
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><div>Hello,<br><br></div>please find an error detecte=
d when is used a combination of &quot;xargs&quot; and &quot;grep&quot;, arg=
uments {} are not substituted in grep construction:<br></div>expected resul=
ts:<br>echo &quot;inga&quot;|grep -c &quot;i&quot;<br>1<br><div>user@box1:~=
$ a=3D&quot;i&quot;; echo `echo &quot;inga&quot;|grep -c $a`<br>1<br></div>=
<div><br></div><div>but was necessary tu use it in combination with xargs:<=
br></div><div><br>user@box1:~$ echo &quot;i&quot; | xargs -I{} echo $(echo =
{} ;a=3D$(echo {}) ; echo $a ; echo &quot;inga&quot;|grep -c $a)<br>i i 0<b=
r>user@box1:~$ echo &quot;i&quot; | xargs -I{} echo $(echo {} ;a=3D`echo {}=
` ; echo $a ; echo &quot;inga&quot;|grep -c $a)<br>i i 0<br>user@box1:~$ ec=
ho &quot;i&quot; | xargs -I{} echo $(echo {} ;a=3D{} ; echo $a ; echo &quot=
;inga&quot;|grep -c $a)<br>i i 0<br>user@box1:~$ echo &quot;i&quot; | xargs=
=C2=A0 -I{} echo `echo {} ;a=3D{} ; echo $a ; echo &quot;inga&quot;|grep -c=
 $a`<br>i i 0<br>user@box1:~$ echo &quot;i&quot; | xargs -I{} echo `echo {}=
 ;a=3D{} ; echo $a ; echo &quot;inga&quot;|grep -c $a`<br>i i 0<br>user@box=
1:~$ echo &quot;i&quot; | xargs -I{} echo `echo {} ;a=3D{} ; echo $a ; echo=
 &quot;inga&quot;|grep -c $a`<br>i i 0<br><br></div><div><br></div><div><br=
></div><div>Thanks,<br></div><div>Sergiu Bordei<br></div></div>

--94eb2c1af5100c89f405593749af--




Acknowledgement sent to Sergiu Bordei <sergiu.bordei@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-grep@HIDDEN. Full text available.
Report forwarded to bug-grep@HIDDEN:
bug#28469; Package grep. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 31 Dec 2019 20:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.