vi can't handle ":! cmd %"

Guy Harris guy at auspex.auspex.com
Tue Dec 4 05:26:18 AEST 1990


>From within vi the following can happen
>:!echo % | od -c
>0000000   f   o   o   .   c  \n
>	346 357 357 256 343 012
>
>Does ksh NOT have a convention that vi and other shells use?

No, "ksh" is lacking a botch that some, but not all, shells have.

I'm somewhat surprised that you're seeing this, given that you say
you're running System V "R3.2.3".  Is that actually a System V Release
3-flavored system, or is this a UNIX PC with its somewhat confusing
release numbers?

UNIX shells originally tended to use the 8th bit internally for quoting.
"ex"/"vi", to its eternal shame, thought it "knew" this, and would quote
the expansion of "%" in commands by turning on the 8th bit of all the
characters in the expansion.

Unfortunately for "ex"/"vi", this changed in System V Release 3; the
Bourne shell was modified *not* to use the 8th bit for quoting, in order
that 8-bit character sets such as ISO Latin 1 could be used in commands,
file names, etc..  "ex"/"vi" was also changed in S5R3 not to bother
quoting the expansion of "%" at all.

Later versions of the Korn shell also don't use the 8th bit for quoting.
The C shell as it comes from Berkeley does, but various vendors have
modified it not to.  I think some version of the Ultrix C shell doesn't,
and the SunOS 4.1 C shell doesn't.  The SunOS 4.1 C shell is the one
upon which the System V Release 4 C shell is based.

If, in fact, your machine is a UNIX PC, it probably has an older version
of "ex"/"vi" that still thinks that shells use the 8th bit for quoting,
and older versions of the Bourne and possibly C shells that do, in fact,
use it for that; however, "ksh88d" is one of the later versions of the
Korn shell, which doesn't use the 8th bit for quoting.

As for your other questions:

> Is vi/ex compiled incorrectly?

The 4.3BSD "ex"/"vi" doesn't have any compile flag to turn off that
quoting, so unless the "ex"/"vi" on your system was modified to have
such a flag, no, it's not compiled incorrectly.

> What flags have to be redefined for vi to pass the filename to 
> the shell with the high order bits unset?

The 4.3BSD "ex"/"vi" has no such flags, so you're stuck unless you can
convince "ksh" to strip the 8th bit off.



More information about the Comp.unix.questions mailing list