Gentoo Archives: gentoo-devhelp

From: Steve Long <slong@××××××××××××××××××.uk>
To: gentoo-devhelp@l.g.o
Subject: [gentoo-devhelp] Re: Wrapping Lines in Ebuils
Date: Wed, 05 Mar 2008 06:08:59
Message-Id: fqldd1$2mm$
In Reply to: [gentoo-devhelp] Wrapping Lines in Ebuils by Thomas Kahle
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. explains quoting and how it affects you in shellscripts; 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 -- it truly is the best guide to BASH on the Net (the linked FAQ is ofc legendary ;) Good luck with it :-) [1] for a good intro to regex, and for the official lowdown on POSIX Basic and Extended RegEx. is the script interface you can (usually-- no ed in base Gentoo ;C) expect on any POSIX-compliant system. -- gentoo-devhelp@l.g.o mailing list