[news.software.b] How many writes can sed do?

bob@pds3 (Robert A. Earl) (02/01/90)

In article <1990Jan31.224431.20355@smsc.sony.com> dce@smsc.Sony.COM (David Elliott) writes:
>The file newsetup contains a number of sed scripts, each of which limit
>the number of files referenced in 'w' commands to 10.  It turns out
>that on the Sony NEWS OS, sed can only use 9 different 'w' files.

I have the same problem here also.  Is there an easy workaround?

Or do I have to patch by hand?
-- 
==============
Robert A. Earl
uunet!pds3!bob

dce@smsc.sony.com (David Elliott) (02/02/90)

In article <1990Feb1.122550.8071@pds3> bob@pds3.UUCP (Robert A. Earl, Network Manager) writes:
>In article <1990Jan31.224431.20355@smsc.sony.com> dce@smsc.Sony.COM (David Elliott) writes:
>>The file newsetup contains a number of sed scripts, each of which limit
>>the number of files referenced in 'w' commands to 10.  It turns out
>>that on the Sony NEWS OS, sed can only use 9 different 'w' files.
>
>I have the same problem here also.  Is there an easy workaround?
>
>Or do I have to patch by hand?

I found that it is also true on a MIPS machine running RISCOS 4.0.
I think that that version of sed comes from System V.

Is it possible that the real limit is 9, but that enough systems
are fixed to make 10 seem OK?

In any case, here's my modified version.  You will need to make
the obvious changes (e.g., smsc, sony, ba, ca, etc.).

#!/bin/sh
# $Header: newsetup.SH,v 4.3.1.2 86/09/05 15:41:04 lwall Exp $
# 
# $Log:	newsetup.SH,v $
# Revision 4.3.1.2  86/09/05  15:41:04  lwall
# Changes for newsgroup renaming.
# 
# Revision 4.3.1.1  85/05/10  11:35:43  lwall
# Branch for patches.
# 
# Revision 4.3  85/05/01  11:43:05  lwall
# Baseline for release with 4.3bsd.
# 

export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)

: syntax: newsetup

: System dependencies
: You will want to change the definitions below to reflect the distribution
: areas around you.  If you have more areas than this you will need to modify
: the sed below.

locorg="smsc"
organization="sony"
city="ba"
state="ca"
cntry="usa"
cont="na"
active="/usr/local/lib/news/active"

dotdir="${DOTDIR-${HOME-$LOGDIR}}"
rm -f $dotdir/.oldnewsrc
echo "Creating .newsrc in $dotdir to be used by news programs."

case $active in
~*) active=`/usr/local/lib/news/rn/filexp $active` ;;
esac

: NOTE: SED WILL NOT TAKE MORE THAN 10 WFILES, SO BEWARE

sort <$active | sed >/tmp/n.tmp$$	\
	-e 's/^\([^ ]*\) .*$/\1:/'	\
	-e '/^control:/{'		\
	-e "  w /tmp/n.test$$"	\
	-e '  d'			\
	-e '}'				\
	-e '/^junk:/{'			\
	-e "  w /tmp/n.test$$"	\
	-e '  d'			\
	-e '}'				\
	-e '/test:/{'			\
	-e "  w /tmp/n.test$$"	\
	-e '  d'			\
	-e '}'				\
	-e "/^net\./{"			\
	-e "  w /tmp/n.net$$"		\
	-e '  d'			\
	-e '}'				\
	-e "/^mod\./{"			\
	-e "  w /tmp/n.mod$$"		\
	-e '  d'			\
	-e '}'				\
	-e "/^$locorg\./{"		\
	-e "  w /tmp/n.$locorg$$"	\
	-e '  d'			\
	-e '}'

sed </tmp/n.tmp$$ >/tmp/n.1tmp$$	\
	-e "/^$organization\./{"	\
	-e "  w /tmp/n.$organization$$"	\
	-e '  d'			\
	-e '}'				\
	-e "/^$city\./{"		\
	-e "  w /tmp/n.$city$$"	\
	-e '  d'			\
	-e '}'				\
	-e "/^$state\./{" 		\
	-e "  w /tmp/n.$state$$"	\
	-e '  d'			\
	-e '}'				\
	-e "/^fa\./{"			\
	-e "  w /tmp/n.fa$$"		\
	-e '  d'			\
	-e '}'

sed </tmp/n.1tmp$$ >/tmp/n.2tmp$$	\
	-e "/^$cntry\./{" 		\
	-e "  w /tmp/n.$cntry$$"	\
	-e '  d'			\
	-e '}'				\
	-e "/^$cont\./{" 		\
	-e "  w /tmp/n.$cont$$"	\
	-e '  d'			\
	-e '}'				\
	-e "/^to\./{"			\
	-e "  w /tmp/n.to$$"		\
	-e '  d'			\
	-e '}'				\
	-e "/^comp\./{"			\
	-e "  w /tmp/n.comp$$"	\
	-e '  d'			\
	-e '}'				\
	-e "/^news\./{"			\
	-e "  w /tmp/n.news$$"	\
	-e '  d'			\
	-e '}'				\
	-e "/^rec\./{"			\
	-e "  w /tmp/n.rec$$"		\
	-e '  d'			\
	-e '}'

sed </tmp/n.2tmp$$ >/tmp/n.local$$	\
	-e "/^sci\./{"			\
	-e "  w /tmp/n.sci$$"		\
	-e '  d'			\
	-e '}'				\
	-e "/^soc\./{"			\
	-e "  w /tmp/n.soc$$"		\
	-e '  d'			\
	-e '}'				\
	-e "/^talk\./{"			\
	-e "  w /tmp/n.talk$$"	\
	-e '  d'			\
	-e '}'				\
	-e "/\./{"			\
	-e "  w /tmp/n.misc$$"	\
	-e '  d'			\
	-e '}'


if /bin/test -s $dotdir/.newsrc ; then
    echo "Saving your current .newsrc as .oldnewsrc..."
    mv -f $dotdir/.newsrc $dotdir/.oldnewsrc
fi

: newsrc order determined here
cat \
    /tmp/n.local$$ \
    /tmp/n.$locorg$$ \
    /tmp/n.$organization$$ \
    /tmp/n.$city$$ \
    /tmp/n.$state$$ \
    /tmp/n.$cntry$$ \
    /tmp/n.$cont$$ \
    /tmp/n.mod$$ \
    /tmp/n.news$$ \
    /tmp/n.comp$$ \
    /tmp/n.sci$$ \
    /tmp/n.rec$$ \
    /tmp/n.soc$$ \
    /tmp/n.misc$$ \
    /tmp/n.talk$$ \
    /tmp/n.net$$ \
    /tmp/n.fa$$ \
    /tmp/n.test$$ \
| uniq >$dotdir/.newsrc

rm -f	/tmp/n.to$$ \
	/tmp/n.tmp$$ \
	/tmp/n.1tmp$$ \
	/tmp/n.2tmp$$ \
	/tmp/n.local$$ \
	/tmp/n.$locorg$$ \
	/tmp/n.$organization$$ \
	/tmp/n.$city$$ \
	/tmp/n.$state$$ \
	/tmp/n.$cntry$$ \
	/tmp/n.$cont$$ \
	/tmp/n.mod$$ \
	/tmp/n.news$$ \
	/tmp/n.comp$$ \
	/tmp/n.sci$$ \
	/tmp/n.soc$$ \
	/tmp/n.rec$$ \
	/tmp/n.talk$$ \
	/tmp/n.net$$ \
	/tmp/n.fa$$ \
	/tmp/n.misc$$ \
	/tmp/n.test$$

cat <<'EOH'
Done.

If you have never used the news system before, you may find the articles
in mod.announce.newuser to be helpful.  There is also a manual entry for rn.

To get rid of newsgroups you aren't interested in, use the 'u' command.
Type h for help at any time while running rn.
EOH
-- 
David Elliott
dce@smsc.sony.com | ...!{uunet,mips}!sonyusa!dce
(408)944-4073
"Never call a crazed psychotic a crazed psychotic."

evanh@sco.COM (Evan A.C. Hunt) (02/02/90)

dce@smsc.Sony.COM (David Elliott) writes:
>The file newsetup contains a number of sed scripts, each of which limit
>the number of files referenced in 'w' commands to 10.  It turns out
>that on the Sony NEWS OS, sed can only use 9 different 'w' files.
>Is the number 10 common for most BSD systems, or is newsetup expecting
>too much in this case?

	SCO XENIX has the same limitation.  As I understand the
problem, sed can have 10 output files, but some implementations
count stdout as one of them.  Here's what I did to my copy to
get it to work.  (This is for patchlevel 40.)

-- cut here --
Index: newsetup.SH
6a7
> 
18d18
< # 
19a20,22
> # M001
> # Under SCO XENIX, sed will only take 9 wfiles, not 10
> 
45c48
< : NOTE: SED WILL NOT TAKE MORE THAN 10 WFILES, SO BEWARE
---
> : NOTE: SED WILL NOT TAKE MORE THAN 9 WFILES, SO BEWARE    (M001)
121,124d123
< 	-e '  d'			\\
< 	-e '}'				\\
< 	-e "/^talk\./{"			\\
< 	-e "  w /tmp/n.talk\$\$"	\\

-- 
    Evan A.C. Hunt			evanh@sco.COM	
    The Santa Cruz Operation, Inc.	uunet!sco!evanh 
    (408) 425-7222			evanh%sco.COM@ucscc.ucsc.EDU

eps@toaster.SFSU.EDU (Eric P. Scott) (02/02/90)

This problem should have been fixed in rn/rrn PL 41.
If you are running PL 40 (or worse), upgrade to PL 44.

(If you are having this problem with PL 44, let Stan Barber know
by mailing to rrn@lib.tmc.edu.)

					-=EPS=-

dce@smsc.sony.com (David Elliott) (02/04/90)

In article <290@toaster.SFSU.EDU> eps@cs.SFSU.EDU (Eric P. Scott) writes:
>This problem should have been fixed in rn/rrn PL 41.
>If you are running PL 40 (or worse), upgrade to PL 44.

This is still broken in PL44 as far as I can tell.

The bug is subtle.  Most people expect sed to handle 10 or more
distinct filenames in w commands.  The problem is that some versions
of sed, apparently those based on System III, but I can't be positive,
only handle 9.

-- 
David Elliott
dce@smsc.sony.com | ...!{uunet,mips}!sonyusa!dce
(408)944-4073
"Never call a crazed psychotic a crazed psychotic."