Subject: csh parsing problem on -current
To: NetBSD current <current-users@netbsd.org>
From: Nicolas Joly <njoly@pasteur.fr>
List: current-users
Date: 05/13/2004 12:00:28
Hi,
I recently noticed that some csh scripts that worked on NetBSD 1.6GZ,
last time i checked, does not work anymore on NetBSD 2.0E (and
probably 2.0_BETA).
Here follow a small script that demonstrate the problem :
njoly@hal [~/tmp]> cat min.csh
#!/bin/csh
while ( $#argv >= 1 )
echo "** $argv[1] **"
switch ( "$argv[1]" )
case "c":
breaksw
case "b":
foreach f ( 1 2 3 )
end
breaksw
case "a":
breaksw
endsw
set argv = ($argv[2-])
end
njoly@hal [~/tmp]> /bin/csh min.csh a b c
** a **
** b **
** c **
end: Not in while/foreach.
njoly@hal [~/tmp]> /bin/csh min.csh a
** a **
njoly@hal [~/tmp]> /bin/csh min.csh b
** b **
njoly@hal [~/tmp]> /bin/csh min.csh c
** c **
end: Not in while/foreach.
njoly@hal [~/tmp]> uname -a
NetBSD hal.sis.pasteur.fr 2.0E NetBSD 2.0E (GENERIC.MP) #0: Wed May 12 17:13:58 CEST 2004 njoly@lanfeust.sis.pasteur.fr:/local/src/NetBSD/obj/i386/sys/arch/i386/compile/GENERIC.MP i386
I tracked down this problem, which is present in `bin/csh/func.c'
since revision 1.27; with this small piece of code :
@@ -627,6 +629,13 @@
return;
break;
case T_END:
+ if (type == T_BRKSW) {
+ wp = whyles;
+ if (wp) {
+ whyles = wp->w_next;
+ wpfree(wp);
+ }
+ }
if (type == T_BREAK)
level--;
break;
Removing this few lines restore the expected behaviour.
Thanks in advance,
Regards.
--
Nicolas Joly
Biological Software and Databanks.
Institut Pasteur, Paris.