public inbox for gentoo-devhelp@lists.gentoo.org
 help / color / mirror / Atom feed
From: Steve Long <slong@rathaus.eclipse.co.uk>
To: gentoo-devhelp@lists.gentoo.org
Subject: [gentoo-devhelp]  Re: Wrapping Lines in Ebuils
Date: Wed, 05 Mar 2008 06:16:08 +0000	[thread overview]
Message-ID: <fqldd1$2mm$1@ger.gmane.org> (raw)
In-Reply-To: 47CBDB72.9020009@gmx.de

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



      reply	other threads:[~2008-03-05  6:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-03 11:05 [gentoo-devhelp] Wrapping Lines in Ebuils Thomas Kahle
2008-03-05  6:16 ` Steve Long [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='fqldd1$2mm$1@ger.gmane.org' \
    --to=slong@rathaus.eclipse.co.uk \
    --cc=gentoo-devhelp@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox