Hi everyone, I am sort of at the end of my wits here, and after a few hours of
trying this on my own, I am stumped. This leans on being OT, however, it will
be used exclusively in helping me with cleaning up a bunch of documentation to
a project, which I will then be making a Portfile for.
I don't think it is appropriate to reinplace the docs as it is going to add a
ton of noise to the Portfile, and be something that is done once in a while by
the developer. I am just working to help the developer keep his documentation
up to date and in a form that is beneficial to the user.
I feel it best to keep this cruft removal out of the Portfile and start with
clean files.
The problem is basic string replacement with variables, here is a hugely
simplified version of the problem...
$cat VERSION.header
# Version: 0.0
# Author: Example <[email protected]>
# Created: 06/18/2010
$cat DOCUMENTATION
_VERSION_HEADER_
Hello, this is the documentation file, there will be other strings in it
such as _TOKEN_ and _OTHER_TOKEN_, which will go on for an arbitrary amount.
The end result of the file DOCUMENTATION should look like this:
$cat DOCUMENTATION
# Version: 0.0
# Author: Example <[email protected]>
# Created: 06/18/2010
Hello, this is the documentation file, there will be other strings in it
such as download link and download2, which will go on for an arbitrary
amount.
Here is my pseudo example, where I have run into issues of loosing the line
endings and the replacements simply not happening. The below of course will
not work at all, but I feel it illustrates well what it is I am trying to do.
Does the Mac OS X sed behave different than the version that most examples I
find online are referring to?
VERSION_HEADER=`cat VERSION.header`
DOWNLOAD='download link'
ALT_DOWNLOAD='download2'
sed -e '/_VERSION_HEADER_/$VERSION_HEADER' DOCUMENTATION
sed -e '/_TOKEN_/$DOWNLOAD' DOCUMENTATION
sed -e '/_OTHER_TOKEN_/$ALT_DOWNLOAD' DOCUMENTATION
Any help would be appreciated. Thanks so much.
--
Scott * If you contact me off list replace talklists@ with scott@ *
_______________________________________________
macports-dev mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macports-dev