Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Jul 1995 11:39:30 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        jhs@vector.eikon.e-technik.tu-muenchen.de, w@cs.tu-berlin.de
Cc:        aturetta@stylo.italia.com, freebsd-hackers@FreeBSD.org, joerg_wunsch@uriah.heep.sax.de
Subject:   Re: your mail
Message-ID:  <199507240139.LAA29063@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>4.4BSD sed is broken. You must quote '/'in brackets, 
>eg. sed -e 's/.*[\/]//'

Is this portable?  I thought that '\' isn't special in brackets.  It isn't
needed even to quote ']' - you can put the ']' first so that it isn't
interpreted as the end of the brackets:

	echo ']' | sed 's/[]]/:-(/'

Quoting of ']' doesn't work:

	echo '\]' | sed 's/[\]]/:-(/	# range is '\', last ']' is literal

Ranges (with a '-') ending with a ']' don't seem to be possible.

This braindamage seems to be inherited from the original ed.  Quotes work
if and only if they are necessary, except for bugs when it wasn't obvious
when they are necessary :-).  This philosophy seems to be implemented in
FreeBSD sed:

	echo '\;' | sed 's/[\;]/:-(/g'	# quote in brackets not nec., so literal
	echo '\/' | sed 's/[\/]/:-(/g'	# bug: quote not nec., but not literal

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199507240139.LAA29063>