[unix-pc.general] cnews on a 3B1 with ksh

afc@shibaya.lonestar.org (Augustine Cano) (05/24/90)

In article <1990May22.212714.6570@bagend.uucp> jan@bagend.uucp (Jan Isley) writes:
>If I may quote from cnews "problems" doc without getting cancelled by
>merlyn@iwarp.intel.com.the.screeming.idiot.copywrite.censor :-(
>
>	Many people using 3B1s, aka UNIX PCs, run the Korn shell as
>	their bin/sh.  Some other folks may do this too.  Beware that
>	ksh was not fully sh-compatible for a long time, with some
>	subtle differences in the ill-documented behavior of backquotes
>	and backslashes.  Some of the C News shell scripts, notably
>	inews, are known to hit these bugs. We are told that current
>	kshs have fixed them.
>
>Yes, I use ksh.  Pnews and postnews fail to find any newsgroup in
>the active file that has a '.' in it.  I can post to 'general' just 
>fine.  Posting to 'to.bagend' for instance, (or any other equally valid
>mutli word group at my site, like news.software.b) produces:

I encountered the problem too when installing cnews.  The culprit is a
string in inews called `egreppat'.  As it is, with 4 back-slashes, it works
with sh.  To make it work with ksh, it has to have 2.  If you make this
change, it will only work with ksh.  One solution is to modify inews to
use the 4-back-slash egreppat when run by sh and the 2-back-slash one when
run by ksh.  My first solution was to just replace the 4 slashes with 2.
This way, inews would work when I posted from the shell prompt using Pnews.
When posting a followup from within rn, however, inews was run through sh
and it broke the fix.  My current solution, which works in both cases is
to leave egreppat with the 4 slashes and modify Pnews and replace the
line
		if $inews -h < $tmpart ; then
with
		if sh $inews -h < $tmpart ; then

BTW, I'm still using rn PL40.

>  /usr/bin/inews: to.bagend matches no groups in /usr/lib/news/active
>
>If I 'exec sh' before posting, articles go through just fine, of course.
>
>Now, for the stupid questions part:
>
>Given that all of the cnews files begin with '#! /bin/sh', why
>do the processes blindly run off and do their /bin/ksh thing?  If you
>are going to tell me to RTFM about why #! /bin/sh does not work on the
>3B1, please include the page number you found it on, okay?  I missed it.

Some programs that use Larry Wall's Configure script test for this and
tell you that "#! /bin/sh" doesn't work.  Apparently, what works is
": use /bin/sh".  I suppose one solution would be to replace all "#!..."
with ": use ..."

>Setting SHELL=/bin/sh, exporting SHELL or not, making inews or Pnews
>or postnews suid or guid etc, etc, etc... has the same effect.  If the
>user is using ksh, everything else uses ksh.
>
>Now, if I could just find that nomex suit I had ....
>-- 
>Signatures!?                          | Jan Isley  jan@bagend
>We don't need no stinking signatures. | known_universe!gatech!bagend!jan 

I hope this helps...

Augustine Cano		afc@shibaya.lonestar.org

jan@bagend.uucp (Jan Isley) (05/25/90)

In article <1990May22.212714.6570@bagend.uucp> I wrote:

>[ a variety of boo hoos about postnews not working with my ksh.]

Thanks for all (well, most) of the replys.

And the winner was, From: csvax.caltech.edu!andy (Andy Fyfe)

He pointed out that the version of ksh that was available from the
STORE, now osu-cis archives (thanks Brant, et. al.) is a later version
than the distribution ksh.  It even came with documentation!

andy>They are not the same.  Among other things, the STORE ksh claims
andy>to be "Version 06/03/86", accepts syntax such as $(date) and ${12},
andy>and comes complete with /etc/suid_exec.

andy>It also gets through both the perl Configure and cnews build scripts
andy>without spitting up.  The version from fixdisk 2 spat up on at least
andy>one or the other.

If you can read this you know that it must have worked.

I got several suggestions to try ": use /bin/sh" instead.  I know
that works on my XENIX box but it did not work for my 3b.

Others wanted to know how I could be so stupid to not know that
#! /bin/sh was not a SYSVism... Well they have quit reading this
by now anyway.

thanks
-- 
Signatures!?                          | Jan Isley  jan@bagend
We don't need no stinking signatures. | known_universe!gatech!bagend!jan 

ruck@sphere.UUCP (John R Ruckstuhl Jr) (05/26/90)

In article <1990May23.190938.16011@shibaya.lonestar.org>, afc@shibaya.lonestar.org (Augustine Cano) writes:
> Some programs that use Larry Wall's Configure script test for this and
> tell you that "#! /bin/sh" doesn't work.  Apparently, what works is
> ": use /bin/sh".  I suppose one solution would be to replace all "#!..."
> with ": use ..."

With all due respect to Mr Wall, when I last used "Configure" on an AT&T
3B1, it informed me (correctly) that "#! /bin/sh" didn't work, but
misled me by saying that ": use /bin/sh" did work.  (This Configure was
bundled with rn patchlevel ?40?)

Isn't it easy to test?  Invoke a script like
    : use /bin/sh	# or whatever you think *might* work
    ps
from whatever shells you hope will respect that first line, and examine
output.  This is how I proved to myself that ": use /bin/sh" doesn't 
work with the Korn Shell I use on the 3B1.
-- 
John R Ruckstuhl, Jr	UUCP: sphere!ruck (or hplabs!hp-lsd!sphere!ruck)
			DOMAIN: ruck%sphere@hp-lsd.cos.hp.com

eggert@twinsun.com (Paul Eggert) (05/26/90)

afc@shibaya.UUCP (Augustine Cano) writes:

	I encountered the problem too when installing cnews.  The culprit is a
	string in inews called `egreppat'.  As it is, with 4 back-slashes, it
	works with sh.  To make it work with ksh, it has to have 2.  If you
	make this change, it will only work with ksh.

I assume you mean the following code.

	egreppat="^(` sed -e 's/[.+*()|[]/\\\\&/g' -e 's/,/|/g' <$nglist `) "

Why not just rewrite it as follows?
This should work with both sh and ksh.

	sedscript='s/[.+*()|[]/\\&/g; s/,/|/g'
	grouppat=` sed "$sedscript" <$nglist `
	egreppat="^($grouppat) "

scs@lokkur.dexter.mi.us (Steve Simmons) (05/26/90)

ruck@sphere.UUCP (John R Ruckstuhl Jr) writes:

>With all due respect to Mr Wall, when I last used "Configure" on an AT&T
>3B1, it informed me (correctly) that "#! /bin/sh" didn't work, but
>misled me by saying that ": use /bin/sh" did work.  (This Configure was
>bundled with rn patchlevel ?40?)

>Isn't it easy to test?  Invoke a script like
>    : use /bin/sh	# or whatever you think *might* work
>    ps
>from whatever shells you hope will respect that first line, and examine
>output.  This is how I proved to myself that ": use /bin/sh" doesn't 
>work with the Korn Shell I use on the 3B1.

The way Larry puts it is misleading.  The test being performed is not
"does ': <program>' make '<program>' execute this shell file", but rather
"does a line starting with ':' make the bourne shell execute this shell
file".  ':' is 'always true' in bourne shells, and on many systems that
normally default execution to the users' shell, this will give you a
bourne execution instead.

jbm@celebr.uucp (John B. Milton) (06/01/90)

In article <1990May23.190938.16011@shibaya.lonestar.org> afc@shibaya.UUCP (Augustine Cano) writes:
>In article <1990May22.212714.6570@bagend.uucp> jan@bagend.uucp (Jan Isley) writes:
...
>I encountered the problem too when installing cnews.  The culprit is a
>string in inews called `egreppat'.  As it is, with 4 back-slashes, it works
>with sh.  To make it work with ksh, it has to have 2.  If you make this
>change, it will only work with ksh.  One solution is to modify inews to
>use the 4-back-slash egreppat when run by sh and the 2-back-slash one when
>run by ksh.  My first solution was to just replace the 4 slashes with 2.
>This way, inews would work when I posted from the shell prompt using Pnews.
>When posting a followup from within rn, however, inews was run through sh
>and it broke the fix.  My current solution, which works in both cases is
>to leave egreppat with the 4 slashes and modify Pnews and replace the
>line
>		if $inews -h < $tmpart ; then
>with
>		if sh $inews -h < $tmpart ; then

The problem is NOT with Pnews, it's inews.

My solution was to patch inews, adding the + lines:

+if [ "$RANDOM" = "$RANDOM" ]; then
	egreppat="^(` sed -e 's/[.+*()|[]/\\\\&/g' -e 's/,/|/g' <$nglist `) "
+else
+	egreppat="^(` sed -e 's/[.+*()|[]/\\&/g' -e 's/,/|/g' <$nglist `) "
+fi

Everytime ksh evaluates the environment variable RANDOM, ksh changes it to a
different random number, which /bin/sh does not do. I sent this fix off to
the cnews folks. I have not tested the behavior of a ksh88, so this may not
be a global solution.

John
-- 
John Bly Milton IV, jbm@uncle.UUCP, n8emr!uncle!jbm@osu-cis.cis.ohio-state.edu
(614) h:252-8544, w:469-1990; N8KSN, AMPR: 44.70.0.52; Don't FLAME, inform!