Re: [dev] print utility

From: Chris Down <>
Date: Tue, 2 Apr 2013 12:53:48 +0800

On 2013-04-02 15:36, Sam Watkins wrote:
> I reckon by far the most common thing people do with sed is to replace
> one (sort of) string with another. But even this "core sed business"
> is ridiculous with sed.
> e.g. A=/usr/bin B=/bin sed 's/$A/$B/' <in >out # won't work
> Changing delimiters doesn't help for the general case. I would have to
> escape any input string before sed can handle it, which is more difficult
> than writing a better substitute process.

This is not a problem with sed, this is a problem with your thinking process.
You can't just arbitrarily inject strings to be evaled in a program and expect
it to end well. It's your responsibility to sanitise input if you are going to
do this.

> sed is over-complex and so it's stupid even at its simplest core business.

Perhaps it is what *you* use sed for, but to conflate that with the needs of sed
users at large is just egoism and ignorance. A quick look through my shell
history suggests it only accounts for maybe 5% of my use cases, most of the time
I'm grepping between two patterns, getting individual lines, or doing other
stuff like that. I'm also not representative of the sed community, but to
suggest that this is what people primarily use it for is just ignorant. Even if
that was true, it's irrelevant. Sed is not a tool to do search/replace. Sed is a
specific DSL for text processing. You can't arbitrarily inject strings into C
code either, does that make it suck? No, because you're doing it wrong.

Received on Tue Apr 02 2013 - 06:53:48 CEST

This archive was generated by hypermail 2.3.0 : Tue Apr 02 2013 - 07:00:08 CEST