4

I'd just want to get confirmation on (and maybe some background to) the way that Bill Joy's vi, sometimes found as traditional-vi on some BSD systems, handles regular expressions.

It seems as if most "special characters" needs to be escaped.

Writing, e.g., :s/./x/g will not replace all characters on the line with x, but :s/\./x/g will.

Likewise, * needs to be escaped and the first [ of any character group.

Is this the historic behaviour of Bill's implementation of vi?

I'm testing on OpenBSD 6.1-stable with the traditional-vi-20050325p0 package, which takes its sources from http://ex-vi.sourceforge.net/

The document entitled "Changes in ex and vi" mentions "traditional regular expressions". However, I have not found any place detailing what the differences are between these and modern POSIX BREs and EREs. Or whether "traditional" in this context is the same as "basic" (as in BRE) or if the escaping of . and * etc. has anything to do with an older type of regular expressions at all.

1 Answer 1

5

It's always been my understanding that vi followed the POSIX standard (BRE/ERE). Given the far more tight-knit technical community/ecosystem of the time I think he would have to have been a bit mad to veer from the standard of the time if he wanted people to adopt his editor.

I don't currently have any direct evidence for this (like a quote from Bill himself) but this 1997 Vi/Ex Reference Manual (PDF, page USD:13-10) says...

The regular expressions supported by ex/vi are, by default, the Basic Regular Expressions (BRE’s) described in the IEEE POSIX Standard 1003.2. The extended option causes all regular expressions to be interpreted as the Extended Regular Expressions (ERE’s) described by the same standard.

Note also the immediately following text which talks about special meaning characters and the "magic" business a bit so that is evidence that it is the "historic behavior" you mention, IMO.

1
  • Ah, traditional vi doesn't set magic by default! That explains a whole lot. Many thanks! Commented Sep 17, 2017 at 6:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.