Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!mailrus!tut.cis.ohio-state.edu!mandrill!hal!ncoast!fmsrl7!nucleus!msm
From: msm@nucleus.UUCP (Michael S. Mattone)
Newsgroups: comp.os.minix
Subject: shell script arg bug?
Keywords: MINIX shell bug
Message-ID: <1201@nucleus.UUCP>
Date: 27 Jun 88 23:12:13 GMT
Organization: The Nucleus Public Access Unix, Clarkston, MI
Lines: 26


There seems to be a problem with arguments to shell scripts.  I noticed
the trouble when I tried a yes(1) script posted a while ago:
 
	while : ; do
		echo ${1-y}
	done
 
When run without an argument a stream of empty lines is produced
instead of y's.  When an argument is given the script functions
properly.
 
I think the two diffs below show how to fix the problem.
 
sh1.c:
------
165c165
< 	setval(lookup("#"), putn(dolc-1));
---
> 	setval(lookup("#"), putn(--dolc));	/* was: dolc-1 */
 
sh3.c:
------
119c119
< 			if ((i = dolc-1) < 0)
---
> 			if ((i = dolc) < 0)	/* was: dolc-1 */