1 |
Thomas Kahle wrote: |
2 |
> how do I properly wrap lines in ebuilds, specifically the "\" tends give |
3 |
> me errors when i try to wrap a long sed line like: |
4 |
> |
5 |
> sed -i -e "s,\$\(grisbi_LDFLAGS\) |
6 |
> \$\(grisbi_OBJECTS\),\$\(grisbi_OBJECTS\) \$\(grisbi_LDFLAGS\) |
7 |
> \$\(LDFLAGS\),g" src/Makefile |
8 |
> |
9 |
Well if it's quoted, BASH is fine with it, but obviously it forms part of |
10 |
the string. The easiest way to maintain readability (if long lines bother |
11 |
you) is to just keep adding to a string, var+='foo bar' |
12 |
|
13 |
-e is not needed unless you're passing more than one sed command (and most |
14 |
modern day sed's, including FBSD afaik are happy with ; as a separator) and |
15 |
the g flag looks a bit odd since sed is line-based; do you need to replace |
16 |
that string more than once per-line? |
17 |
|
18 |
A more fundamental point here is confusion over quoting; you should be using |
19 |
strong (single) quotes, since you're trying to avoid parameter expansion. |
20 |
http://bash-hackers.org/wiki/doku.php?id=syntax:words explains quoting and |
21 |
how it affects you in shellscripts; http://www.grymoire.com/Unix/Quote.html |
22 |
has good examples of use with various utilities. |
23 |
|
24 |
\( doesn't translate into a ( in "" like \$ does; eg: echo "\$\(foo\)" so |
25 |
you're using \( .. \) which is used to delimit sub-expressions in BRE[1] |
26 |
|
27 |
So in sum, I'd do this (assuming g is needed): |
28 |
local cmd # [don't pollute the vdb/binpkg] |
29 |
cmd='s,$(grisbi_LDFLAGS) $(grisbi_OBJECTS)' |
30 |
cmd+=',$(grisbi_OBJECTS) $(grisbi_LDFLAGS) $(LDFLAGS),g' |
31 |
sed -i "$cmd" src/Makefile |
32 |
|
33 |
BTW I heartily recommend http://wooledge.org:8000/BashGuide -- it truly is |
34 |
the best guide to BASH on the Net (the linked FAQ is ofc legendary ;) |
35 |
|
36 |
Good luck with it :-) |
37 |
|
38 |
[1] http://www.grymoire.com/Unix/Regular.html for a good intro to regex, and |
39 |
http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html#tag_09_03 |
40 |
for the official lowdown on POSIX Basic and Extended RegEx. |
41 |
http://www.opengroup.org/onlinepubs/009695399/functions/contents.html is the |
42 |
script interface you can (usually-- no ed in base Gentoo ;C) expect on any |
43 |
POSIX-compliant system. |
44 |
|
45 |
|
46 |
-- |
47 |
gentoo-devhelp@l.g.o mailing list |