From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([69.77.167.62] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1JWmoF-0006KF-Ns for garchives@archives.gentoo.org; Wed, 05 Mar 2008 06:08:59 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0819FE0238; Wed, 5 Mar 2008 06:08:59 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id D7768E0238 for ; Wed, 5 Mar 2008 06:08:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 764CC65EE0 for ; Wed, 5 Mar 2008 06:08:58 +0000 (UTC) X-Virus-Scanned: amavisd-new at gentoo.org X-Spam-Score: -0.265 X-Spam-Level: X-Spam-Status: No, score=-0.265 required=5.5 tests=[AWL=0.266, BAYES_00=-2.599, RCVD_NUMERIC_HELO=2.067, WEIRD_PORT=0.001] 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 EsS1xu79msVo for ; Wed, 5 Mar 2008 06:08:51 +0000 (UTC) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTP id AC360661A7 for ; Wed, 5 Mar 2008 06:08:50 +0000 (UTC) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1JWmnz-0001x5-W7 for gentoo-devhelp@gentoo.org; Wed, 05 Mar 2008 06:08:44 +0000 Received: from 82.152.193.31 ([82.152.193.31]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 05 Mar 2008 06:08:43 +0000 Received: from slong by 82.152.193.31 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 05 Mar 2008 06:08:43 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: gentoo-devhelp@lists.gentoo.org From: Steve Long Subject: [gentoo-devhelp] Re: Wrapping Lines in Ebuils Date: Wed, 05 Mar 2008 06:16:08 +0000 Message-ID: References: <47CBDB72.9020009@gmx.de> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Development-related help X-BeenThere: gentoo-devhelp@gentoo.org X-BeenThere: gentoo-devhelp@lists.gentoo.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 82.152.193.31 User-Agent: KNode/0.10.5 Sender: news X-Archives-Salt: 04179159-01f9-42ca-bbf6-8a259ccdc372 X-Archives-Hash: a133d10a1712863aa2f33ed1c97d3ddd Thomas Kahle wrote: > how do I properly wrap lines in ebuilds, specifically the "\" tends give > me errors when i try to wrap a long sed line like: > > sed -i -e "s,\$\(grisbi_LDFLAGS\) > \$\(grisbi_OBJECTS\),\$\(grisbi_OBJECTS\) \$\(grisbi_LDFLAGS\) > \$\(LDFLAGS\),g" src/Makefile > Well if it's quoted, BASH is fine with it, but obviously it forms part of the string. The easiest way to maintain readability (if long lines bother you) is to just keep adding to a string, var+='foo bar' -e is not needed unless you're passing more than one sed command (and most modern day sed's, including FBSD afaik are happy with ; as a separator) and the g flag looks a bit odd since sed is line-based; do you need to replace that string more than once per-line? A more fundamental point here is confusion over quoting; you should be using strong (single) quotes, since you're trying to avoid parameter expansion. http://bash-hackers.org/wiki/doku.php?id=syntax:words explains quoting and how it affects you in shellscripts; http://www.grymoire.com/Unix/Quote.html has good examples of use with various utilities. \( doesn't translate into a ( in "" like \$ does; eg: echo "\$\(foo\)" so you're using \( .. \) which is used to delimit sub-expressions in BRE[1] So in sum, I'd do this (assuming g is needed): local cmd # [don't pollute the vdb/binpkg] cmd='s,$(grisbi_LDFLAGS) $(grisbi_OBJECTS)' cmd+=',$(grisbi_OBJECTS) $(grisbi_LDFLAGS) $(LDFLAGS),g' sed -i "$cmd" src/Makefile BTW I heartily recommend http://wooledge.org:8000/BashGuide -- it truly is the best guide to BASH on the Net (the linked FAQ is ofc legendary ;) Good luck with it :-) [1] http://www.grymoire.com/Unix/Regular.html for a good intro to regex, and http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html#tag_09_03 for the official lowdown on POSIX Basic and Extended RegEx. http://www.opengroup.org/onlinepubs/009695399/functions/contents.html is the script interface you can (usually-- no ed in base Gentoo ;C) expect on any POSIX-compliant system. -- gentoo-devhelp@lists.gentoo.org mailing list