[comp.editors] vi can't handle ":! cmd %"

btwomey@cbnewsj.att.com (william.tw0mey) (11/28/90)

I'm running System V, R3.2.3 and ksh88d. While in vi editing
foo.c, with shell=/bin/ksh, if I try

:! cc %

I get a message to the effect that cc can't access foo.c.
Now the interesting part is if I try

:!echo % | od -c

I get
0000000   f   o   o   .   c  \n
	346 357 357 256 343 012
0000006

which is the characters for "foo.c" but with the high order bits set.

Is vi/ex compiled incorrectly?

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

Thanks,
Bill Twomey, cbnewsj!btwomey attmail!btwomey journey!btwomey

btwomey@cbnewsj.att.com (william.tw0mey) (11/28/90)

Re: Message-ID: <1990Nov27.210425.25747@cbnewsj.att.com>

For those of you that have replied to me, thanks.
Let me clarify my post, I am editing an existing file.

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?

Thanks,
Bill Twomey, cbnewsj!btwomey attmail!btwomey journey!btwomey

guy@auspex.auspex.com (Guy Harris) (12/04/90)

>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.