From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1SZMk6-0003aP-Kp for garchives@archives.gentoo.org; Tue, 29 May 2012 13:45:46 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 08B73E091C; Tue, 29 May 2012 13:45:31 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 39F14E083C for ; Tue, 29 May 2012 13:44:48 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 98AF61B403A for ; Tue, 29 May 2012 13:44:47 +0000 (UTC) X-Virus-Scanned: by amavisd-new using ClamAV at gentoo.org X-Spam-Flag: NO X-Spam-Score: -1.109 X-Spam-Level: X-Spam-Status: No, score=-1.109 tagged_above=-999 required=5.5 tests=[AWL=-0.361, BAYES_00=-1.9, RCVD_NUMERIC_HELO=1.164, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=no Received: from smtp.gentoo.org ([127.0.0.1]) by localhost (smtp.gentoo.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6fZX0vh_R_y3 for ; Tue, 29 May 2012 13:44:40 +0000 (UTC) Received: from plane.gmane.org (plane.gmane.org [80.91.229.3]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id AF6F21B4038 for ; Tue, 29 May 2012 13:44:38 +0000 (UTC) Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1SZMiw-0001gA-PU for gentoo-dev@gentoo.org; Tue, 29 May 2012 15:44:34 +0200 Received: from 91.85.62.252 ([91.85.62.252]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 29 May 2012 15:44:34 +0200 Received: from slong by 91.85.62.252 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 29 May 2012 15:44:34 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: gentoo-dev@lists.gentoo.org From: Steven J Long Subject: [gentoo-dev] Re: [PATCH eutils] Move remove_libtool_files() from autotools-utils for wider use. Date: Tue, 29 May 2012 14:50:19 +0100 Organization: Friendly-Coders Message-ID: References: <1338191936-2091-1-git-send-email-mgorny@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 91.85.62.252 Content-Transfer-Encoding: quoted-printable X-Archives-Salt: b8ce07f6-3fb8-4b06-abee-5d029bd4802d X-Archives-Hash: 0663d1b8446af774d2276b7508974dc6 Micha=C5=82 G=C3=B3rny wrote: > + find "${D}" -type f -name '*.la' -print0 | while read -r -d '' f;=20 .. > + rm -f "${f}" || die .. > + done Don't pipe to read like that; it means the final command is in a subshell= =20 and "die is /not/ guaranteed to work correctly if called from a subshell=20 environment."[1] More seriously, the script doesn't actually get the correct filenames,=20 despite being written to handle any filename. eg: $ touch $' foo bar \n\t ' $ while read -r -d '' f; do echo "'$f'"; done < <(find . -type f -print0)= =20 './ foo bar' You do it like this: while read -rd ''; do f=3D$REPLY; .. done < <(find "$D" -type f -name '*.la' -print0) eg: $ while read -rd ''; do f=3D$REPLY; echo "'$f'"; done < <(find . -type f = - print0) = =20 './ foo bar = =20 ' Or use: while IFS=3D read -rd '' f; do .. if you prefer. See: help read # in a terminal. It's called 'Process Substitution' if anyone wants to read about it in man bash. The classic example with find is to get the list in an array: arr=3D() while read -rd ''; do arr+=3D("$REPLY") done < <(find "$dir" -type f .. -print0) (perhaps conditionally though that's usually better done within find which can later be handled on a per-file basis, or passed to: foo "${arr[@]}" ..or if you just want to know whether there is a matching file: if read -rd '' < <(find . -type f -print0); then something matched else nothing did fi They're both things I came up with a few years ago when I was learning from #bash, which you are in dire need of, based on reading git-2.eclass. [1] http://dev.gentoo.org/~ulm/pms/head/pms.html#x1-12600011.3.3 (11.3.3.6) --=20 #friendly-coders -- We're friendly, but we're not /that/ friendly ;-)