[comp.os.minix] shell script arg bug?

msm@nucleus.UUCP (Michael S. Mattone) (06/28/88)

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 */