[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: sed question



On 06.12.19 14:40, songbird wrote:
> Greg Wooledge wrote:
> ...
> > Ideally, you'd just stop trying to use sed with user-supplied variables
> > injected into the code.  Sed was never built to be safe for that kind of
> > work.
> 
>   sed was designed to operate on streams.  a sequence of 
> characters is a stream.  i don't see any reason why 
> putting the variable into the middle of that expression 
> means anything different.

If the sed implementation of variable regexes proves problematic, then
there's awk with its Dynamic Regexps. (Section 2.8 of the pdf manual
floating about out there.)

With its C-like syntax, it's less write-only than perl, perhaps because
it is of the same vintage as sed. (And from the same stable.) It does
admittedly tend to view its input stream a line at the time.

Erik


Reply to: