NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/50111: sed does not support \n newline in replacement patterns.
The following reply was made to PR bin/50111; it has been noted by GNATS.
From: Robert Elz <kre%munnari.OZ.AU@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc:
Subject: Re: bin/50111: sed does not support \n newline in replacement patterns.
Date: Sun, 02 Aug 2015 02:59:58 +0700
Date: Sat, 1 Aug 2015 12:25:00 +0000 (UTC)
From: achowe%snert.com@localhost
Message-ID: <20150801122500.515D9A654F%mollari.NetBSD.org@localhost>
Please no.
Because of ...
| Historically, sed did not support "\n" sequences in the substitution
it will always be non-portable to do so - whatever NetBSD's (or gnu's) sed
decides to do. If you really want to use non-portable extensions, just
require & use gnu sed and be done with it.
As for ...
| So for example the current manner of splitting text with a newline is:
[...]
| When the above is used a shell script, any line/block indention would
| be disrupted, because of requiring a backslash and literal newline.
Not necessarily. An example from one of my scripts that does some
manipulation of HTML (this is just a fragment)
NL='
'
sed -e 's!\(.\)\(</*script>\)!\1\'"${NL}"'\2!g' \
-e 's/\(script[^>]*>\)\(.\)/\1\'"${NL}"'\2/g' \
-e 's/\(.\)<div/\1\'"${NL}"'<div/g' \
... [much more] ...
If ${NL} was only to be used in sed subst expressions, the preceding \
could be included in it as well.
kre
Home |
Main Index |
Thread Index |
Old Index