xref: /titanic_50/usr/src/cmd/sh/func.c (revision d6b882a974afe4a3ab38793d5de10bae2e078d39)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*d6b882a9SNobutomo Nakano  * Common Development and Distribution License (the "License").
6*d6b882a9SNobutomo Nakano  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
21965005c8Schin 
22965005c8Schin /*
23*d6b882a9SNobutomo Nakano  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24965005c8Schin  * Use is subject to license terms.
25965005c8Schin  */
26965005c8Schin 
277c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
287c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate /*
317c478bd9Sstevel@tonic-gate  * UNIX shell
327c478bd9Sstevel@tonic-gate  */
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #include	"defs.h"
357c478bd9Sstevel@tonic-gate 
36965005c8Schin static void free_arg(struct argnod *);
37965005c8Schin static void freeio(struct ionod *);
38965005c8Schin static void freereg(struct regnod *);
39965005c8Schin static void prarg(struct argnod *argp);
40965005c8Schin static void prio(struct ionod *iop);
41965005c8Schin 
42965005c8Schin void
freefunc(struct namnod * n)43965005c8Schin freefunc(struct namnod 	*n)
447c478bd9Sstevel@tonic-gate {
457c478bd9Sstevel@tonic-gate 	freetree((struct trenod *)(n->namenv));
467c478bd9Sstevel@tonic-gate }
477c478bd9Sstevel@tonic-gate 
48*d6b882a9SNobutomo Nakano void
freetree(struct trenod * t)49965005c8Schin freetree(struct trenod *t)
507c478bd9Sstevel@tonic-gate {
517c478bd9Sstevel@tonic-gate 	if (t)
527c478bd9Sstevel@tonic-gate 	{
53965005c8Schin 		int type;
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate 		type = t->tretyp & COMMSK;
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate 		switch (type)
587c478bd9Sstevel@tonic-gate 		{
59*d6b882a9SNobutomo Nakano 			case TFND: {
60*d6b882a9SNobutomo Nakano 				struct fndnod *f = fndptr(t);
61*d6b882a9SNobutomo Nakano 
62*d6b882a9SNobutomo Nakano 				if (f->fndref > 0) {
63*d6b882a9SNobutomo Nakano 					f->fndref--;
64*d6b882a9SNobutomo Nakano 					return;
65*d6b882a9SNobutomo Nakano 				}
66*d6b882a9SNobutomo Nakano 				free(f->fndnam);
67*d6b882a9SNobutomo Nakano 				freetree(f->fndval);
687c478bd9Sstevel@tonic-gate 				break;
69*d6b882a9SNobutomo Nakano 			}
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate 			case TCOM:
727c478bd9Sstevel@tonic-gate 				freeio(comptr(t)->comio);
737c478bd9Sstevel@tonic-gate 				free_arg(comptr(t)->comarg);
747c478bd9Sstevel@tonic-gate 				free_arg(comptr(t)->comset);
757c478bd9Sstevel@tonic-gate 				break;
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate 			case TFORK:
787c478bd9Sstevel@tonic-gate 				freeio(forkptr(t)->forkio);
797c478bd9Sstevel@tonic-gate 				freetree(forkptr(t)->forktre);
807c478bd9Sstevel@tonic-gate 				break;
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate 			case TPAR:
837c478bd9Sstevel@tonic-gate 				freetree(parptr(t)->partre);
847c478bd9Sstevel@tonic-gate 				break;
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate 			case TFIL:
877c478bd9Sstevel@tonic-gate 			case TLST:
887c478bd9Sstevel@tonic-gate 			case TAND:
897c478bd9Sstevel@tonic-gate 			case TORF:
907c478bd9Sstevel@tonic-gate 				freetree(lstptr(t)->lstlef);
917c478bd9Sstevel@tonic-gate 				freetree(lstptr(t)->lstrit);
927c478bd9Sstevel@tonic-gate 				break;
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate 			case TFOR:
957c478bd9Sstevel@tonic-gate 			{
967c478bd9Sstevel@tonic-gate 				struct fornod *f = (struct fornod *)t;
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate 				free(f->fornam);
997c478bd9Sstevel@tonic-gate 				freetree(f->fortre);
1007c478bd9Sstevel@tonic-gate 				if (f->forlst)
1017c478bd9Sstevel@tonic-gate 				{
1027c478bd9Sstevel@tonic-gate 					freeio(f->forlst->comio);
1037c478bd9Sstevel@tonic-gate 					free_arg(f->forlst->comarg);
1047c478bd9Sstevel@tonic-gate 					free_arg(f->forlst->comset);
1057c478bd9Sstevel@tonic-gate 					free(f->forlst);
1067c478bd9Sstevel@tonic-gate 				}
1077c478bd9Sstevel@tonic-gate 			}
1087c478bd9Sstevel@tonic-gate 			break;
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate 			case TWH:
1117c478bd9Sstevel@tonic-gate 			case TUN:
1127c478bd9Sstevel@tonic-gate 				freetree(whptr(t)->whtre);
1137c478bd9Sstevel@tonic-gate 				freetree(whptr(t)->dotre);
1147c478bd9Sstevel@tonic-gate 				break;
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate 			case TIF:
1177c478bd9Sstevel@tonic-gate 				freetree(ifptr(t)->iftre);
1187c478bd9Sstevel@tonic-gate 				freetree(ifptr(t)->thtre);
1197c478bd9Sstevel@tonic-gate 				freetree(ifptr(t)->eltre);
1207c478bd9Sstevel@tonic-gate 				break;
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate 			case TSW:
1237c478bd9Sstevel@tonic-gate 				free(swptr(t)->swarg);
1247c478bd9Sstevel@tonic-gate 				freereg(swptr(t)->swlst);
1257c478bd9Sstevel@tonic-gate 				break;
1267c478bd9Sstevel@tonic-gate 		}
1277c478bd9Sstevel@tonic-gate 		free(t);
1287c478bd9Sstevel@tonic-gate 	}
1297c478bd9Sstevel@tonic-gate }
1307c478bd9Sstevel@tonic-gate 
131965005c8Schin static void
free_arg(struct argnod * argp)132965005c8Schin free_arg(struct argnod *argp)
1337c478bd9Sstevel@tonic-gate {
134965005c8Schin 	struct argnod 	*sav;
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate 	while (argp)
1377c478bd9Sstevel@tonic-gate 	{
1387c478bd9Sstevel@tonic-gate 		sav = argp->argnxt;
1397c478bd9Sstevel@tonic-gate 		free(argp);
1407c478bd9Sstevel@tonic-gate 		argp = sav;
1417c478bd9Sstevel@tonic-gate 	}
1427c478bd9Sstevel@tonic-gate }
1437c478bd9Sstevel@tonic-gate 
144965005c8Schin void
freeio(struct ionod * iop)145965005c8Schin freeio(struct ionod *iop)
1467c478bd9Sstevel@tonic-gate {
147965005c8Schin 	struct ionod *sav;
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate 	while (iop)
1507c478bd9Sstevel@tonic-gate 	{
1517c478bd9Sstevel@tonic-gate 		if (iop->iofile & IODOC)
1527c478bd9Sstevel@tonic-gate 		{
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate #ifdef DEBUG
1557c478bd9Sstevel@tonic-gate 			prs("unlinking ");
1567c478bd9Sstevel@tonic-gate 			prs(iop->ioname);
1577c478bd9Sstevel@tonic-gate 			newline();
1587c478bd9Sstevel@tonic-gate #endif
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate 			unlink(iop->ioname);
1617c478bd9Sstevel@tonic-gate 
1627c478bd9Sstevel@tonic-gate 			if (fiotemp == iop)
1637c478bd9Sstevel@tonic-gate 				fiotemp = iop->iolst;
1647c478bd9Sstevel@tonic-gate 			else
1657c478bd9Sstevel@tonic-gate 			{
1667c478bd9Sstevel@tonic-gate 				struct ionod *fiop = fiotemp;
1677c478bd9Sstevel@tonic-gate 
1687c478bd9Sstevel@tonic-gate 				while (fiop->iolst != iop)
1697c478bd9Sstevel@tonic-gate 					fiop = fiop->iolst;
1707c478bd9Sstevel@tonic-gate 
1717c478bd9Sstevel@tonic-gate 				fiop->iolst = iop->iolst;
1727c478bd9Sstevel@tonic-gate 			}
1737c478bd9Sstevel@tonic-gate 		}
1747c478bd9Sstevel@tonic-gate 		free(iop->ioname);
1757c478bd9Sstevel@tonic-gate 		free(iop->iolink);
1767c478bd9Sstevel@tonic-gate 		sav = iop->ionxt;
1777c478bd9Sstevel@tonic-gate 		free(iop);
1787c478bd9Sstevel@tonic-gate 		iop = sav;
1797c478bd9Sstevel@tonic-gate 	}
1807c478bd9Sstevel@tonic-gate }
1817c478bd9Sstevel@tonic-gate 
182965005c8Schin static void
freereg(struct regnod * regp)183965005c8Schin freereg(struct regnod *regp)
1847c478bd9Sstevel@tonic-gate {
185965005c8Schin 	struct regnod 	*sav;
1867c478bd9Sstevel@tonic-gate 
1877c478bd9Sstevel@tonic-gate 	while (regp)
1887c478bd9Sstevel@tonic-gate 	{
1897c478bd9Sstevel@tonic-gate 		free_arg(regp->regptr);
1907c478bd9Sstevel@tonic-gate 		freetree(regp->regcom);
1917c478bd9Sstevel@tonic-gate 		sav = regp->regnxt;
1927c478bd9Sstevel@tonic-gate 		free(regp);
1937c478bd9Sstevel@tonic-gate 		regp = sav;
1947c478bd9Sstevel@tonic-gate 	}
1957c478bd9Sstevel@tonic-gate }
1967c478bd9Sstevel@tonic-gate 
1977c478bd9Sstevel@tonic-gate 
198965005c8Schin static int nonl = 0;
1997c478bd9Sstevel@tonic-gate 
200965005c8Schin void
prbgnlst(void)201965005c8Schin prbgnlst(void)
2027c478bd9Sstevel@tonic-gate {
2037c478bd9Sstevel@tonic-gate 	if (nonl)
2047c478bd9Sstevel@tonic-gate 		prc_buff(SPACE);
2057c478bd9Sstevel@tonic-gate 	else
2067c478bd9Sstevel@tonic-gate 		prc_buff(NL);
2077c478bd9Sstevel@tonic-gate }
2087c478bd9Sstevel@tonic-gate 
209965005c8Schin void
prendlst(void)210965005c8Schin prendlst(void)
2117c478bd9Sstevel@tonic-gate {
2127c478bd9Sstevel@tonic-gate 	if (nonl) {
2137c478bd9Sstevel@tonic-gate 		prc_buff(';');
2147c478bd9Sstevel@tonic-gate 		prc_buff(SPACE);
2157c478bd9Sstevel@tonic-gate 	}
2167c478bd9Sstevel@tonic-gate 	else
2177c478bd9Sstevel@tonic-gate 		prc_buff(NL);
2187c478bd9Sstevel@tonic-gate }
2197c478bd9Sstevel@tonic-gate 
220965005c8Schin void
prcmd(struct trenod * t)221965005c8Schin prcmd(struct trenod *t)
2227c478bd9Sstevel@tonic-gate {
2237c478bd9Sstevel@tonic-gate 	nonl++;
2247c478bd9Sstevel@tonic-gate 	prf(t);
2257c478bd9Sstevel@tonic-gate 	nonl = 0;
2267c478bd9Sstevel@tonic-gate }
2277c478bd9Sstevel@tonic-gate 
228965005c8Schin void
prf(struct trenod * t)229965005c8Schin prf(struct trenod *t)
2307c478bd9Sstevel@tonic-gate {
2317c478bd9Sstevel@tonic-gate 	sigchk();
2327c478bd9Sstevel@tonic-gate 
2337c478bd9Sstevel@tonic-gate 	if (t)
2347c478bd9Sstevel@tonic-gate 	{
235965005c8Schin 		int	type;
2367c478bd9Sstevel@tonic-gate 
2377c478bd9Sstevel@tonic-gate 		type = t->tretyp & COMMSK;
2387c478bd9Sstevel@tonic-gate 
2397c478bd9Sstevel@tonic-gate 		switch(type)
2407c478bd9Sstevel@tonic-gate 		{
2417c478bd9Sstevel@tonic-gate 			case TFND:
2427c478bd9Sstevel@tonic-gate 			{
243965005c8Schin 				struct fndnod *f = (struct fndnod *)t;
2447c478bd9Sstevel@tonic-gate 
2457c478bd9Sstevel@tonic-gate 				prs_buff(f->fndnam);
2467c478bd9Sstevel@tonic-gate 				prs_buff("(){");
2477c478bd9Sstevel@tonic-gate 				prbgnlst();
2487c478bd9Sstevel@tonic-gate 				prf(f->fndval);
2497c478bd9Sstevel@tonic-gate 				prbgnlst();
2507c478bd9Sstevel@tonic-gate 				prs_buff("}");
2517c478bd9Sstevel@tonic-gate 				break;
2527c478bd9Sstevel@tonic-gate 			}
2537c478bd9Sstevel@tonic-gate 
2547c478bd9Sstevel@tonic-gate 			case TCOM:
2557c478bd9Sstevel@tonic-gate 				if (comptr(t)->comset) {
2567c478bd9Sstevel@tonic-gate 					prarg(comptr(t)->comset);
2577c478bd9Sstevel@tonic-gate 					prc_buff(SPACE);
2587c478bd9Sstevel@tonic-gate 				}
2597c478bd9Sstevel@tonic-gate 				prarg(comptr(t)->comarg);
2607c478bd9Sstevel@tonic-gate 				prio(comptr(t)->comio);
2617c478bd9Sstevel@tonic-gate 				break;
2627c478bd9Sstevel@tonic-gate 
2637c478bd9Sstevel@tonic-gate 			case TFORK:
2647c478bd9Sstevel@tonic-gate 				prf(forkptr(t)->forktre);
2657c478bd9Sstevel@tonic-gate 				prio(forkptr(t)->forkio);
2667c478bd9Sstevel@tonic-gate 				if (forkptr(t)->forktyp & FAMP)
2677c478bd9Sstevel@tonic-gate 					prs_buff(" &");
2687c478bd9Sstevel@tonic-gate 				break;
2697c478bd9Sstevel@tonic-gate 
2707c478bd9Sstevel@tonic-gate 			case TPAR:
2717c478bd9Sstevel@tonic-gate 				prs_buff("(");
2727c478bd9Sstevel@tonic-gate 				prf(parptr(t)->partre);
2737c478bd9Sstevel@tonic-gate 				prs_buff(")");
2747c478bd9Sstevel@tonic-gate 				break;
2757c478bd9Sstevel@tonic-gate 
2767c478bd9Sstevel@tonic-gate 			case TFIL:
2777c478bd9Sstevel@tonic-gate 				prf(lstptr(t)->lstlef);
2787c478bd9Sstevel@tonic-gate 				prs_buff(" | ");
2797c478bd9Sstevel@tonic-gate 				prf(lstptr(t)->lstrit);
2807c478bd9Sstevel@tonic-gate 				break;
2817c478bd9Sstevel@tonic-gate 
2827c478bd9Sstevel@tonic-gate 			case TLST:
2837c478bd9Sstevel@tonic-gate 				prf(lstptr(t)->lstlef);
2847c478bd9Sstevel@tonic-gate 				prendlst();
2857c478bd9Sstevel@tonic-gate 				prf(lstptr(t)->lstrit);
2867c478bd9Sstevel@tonic-gate 				break;
2877c478bd9Sstevel@tonic-gate 
2887c478bd9Sstevel@tonic-gate 			case TAND:
2897c478bd9Sstevel@tonic-gate 				prf(lstptr(t)->lstlef);
2907c478bd9Sstevel@tonic-gate 				prs_buff(" && ");
2917c478bd9Sstevel@tonic-gate 				prf(lstptr(t)->lstrit);
2927c478bd9Sstevel@tonic-gate 				break;
2937c478bd9Sstevel@tonic-gate 
2947c478bd9Sstevel@tonic-gate 			case TORF:
2957c478bd9Sstevel@tonic-gate 				prf(lstptr(t)->lstlef);
2967c478bd9Sstevel@tonic-gate 				prs_buff(" || ");
2977c478bd9Sstevel@tonic-gate 				prf(lstptr(t)->lstrit);
2987c478bd9Sstevel@tonic-gate 				break;
2997c478bd9Sstevel@tonic-gate 
3007c478bd9Sstevel@tonic-gate 			case TFOR:
3017c478bd9Sstevel@tonic-gate 				{
302965005c8Schin 					struct argnod	*arg;
303965005c8Schin 					struct fornod 	*f = (struct fornod *)t;
3047c478bd9Sstevel@tonic-gate 
3057c478bd9Sstevel@tonic-gate 					prs_buff("for ");
3067c478bd9Sstevel@tonic-gate 					prs_buff(f->fornam);
3077c478bd9Sstevel@tonic-gate 
3087c478bd9Sstevel@tonic-gate 					if (f->forlst)
3097c478bd9Sstevel@tonic-gate 					{
3107c478bd9Sstevel@tonic-gate 						arg = f->forlst->comarg;
3117c478bd9Sstevel@tonic-gate 						prs_buff(" in");
3127c478bd9Sstevel@tonic-gate 
3137c478bd9Sstevel@tonic-gate 						while(arg != ENDARGS)
3147c478bd9Sstevel@tonic-gate 						{
3157c478bd9Sstevel@tonic-gate 							prc_buff(SPACE);
3167c478bd9Sstevel@tonic-gate 							prs_buff(arg->argval);
3177c478bd9Sstevel@tonic-gate 							arg = arg->argnxt;
3187c478bd9Sstevel@tonic-gate 						}
3197c478bd9Sstevel@tonic-gate 					}
3207c478bd9Sstevel@tonic-gate 
3217c478bd9Sstevel@tonic-gate 					prendlst();
3227c478bd9Sstevel@tonic-gate 					prs_buff("do");
3237c478bd9Sstevel@tonic-gate 					prbgnlst();
3247c478bd9Sstevel@tonic-gate 					prf(f->fortre);
3257c478bd9Sstevel@tonic-gate 					prendlst();
3267c478bd9Sstevel@tonic-gate 					prs_buff("done");
3277c478bd9Sstevel@tonic-gate 				}
3287c478bd9Sstevel@tonic-gate 				break;
3297c478bd9Sstevel@tonic-gate 
3307c478bd9Sstevel@tonic-gate 			case TWH:
3317c478bd9Sstevel@tonic-gate 			case TUN:
3327c478bd9Sstevel@tonic-gate 				if (type == TWH)
3337c478bd9Sstevel@tonic-gate 					prs_buff("while ");
3347c478bd9Sstevel@tonic-gate 				else
3357c478bd9Sstevel@tonic-gate 					prs_buff("until ");
3367c478bd9Sstevel@tonic-gate 				prf(whptr(t)->whtre);
3377c478bd9Sstevel@tonic-gate 				prendlst();
3387c478bd9Sstevel@tonic-gate 				prs_buff("do");
3397c478bd9Sstevel@tonic-gate 				prbgnlst();
3407c478bd9Sstevel@tonic-gate 				prf(whptr(t)->dotre);
3417c478bd9Sstevel@tonic-gate 				prendlst();
3427c478bd9Sstevel@tonic-gate 				prs_buff("done");
3437c478bd9Sstevel@tonic-gate 				break;
3447c478bd9Sstevel@tonic-gate 
3457c478bd9Sstevel@tonic-gate 			case TIF:
3467c478bd9Sstevel@tonic-gate 			{
3477c478bd9Sstevel@tonic-gate 				struct ifnod *f = (struct ifnod *)t;
3487c478bd9Sstevel@tonic-gate 
3497c478bd9Sstevel@tonic-gate 				prs_buff("if ");
3507c478bd9Sstevel@tonic-gate 				prf(f->iftre);
3517c478bd9Sstevel@tonic-gate 				prendlst();
3527c478bd9Sstevel@tonic-gate 				prs_buff("then");
3537c478bd9Sstevel@tonic-gate 				prendlst();
3547c478bd9Sstevel@tonic-gate 				prf(f->thtre);
3557c478bd9Sstevel@tonic-gate 
3567c478bd9Sstevel@tonic-gate 				if (f->eltre)
3577c478bd9Sstevel@tonic-gate 				{
3587c478bd9Sstevel@tonic-gate 					prendlst();
3597c478bd9Sstevel@tonic-gate 					prs_buff("else");
3607c478bd9Sstevel@tonic-gate 					prendlst();
3617c478bd9Sstevel@tonic-gate 					prf(f->eltre);
3627c478bd9Sstevel@tonic-gate 				}
3637c478bd9Sstevel@tonic-gate 
3647c478bd9Sstevel@tonic-gate 				prendlst();
3657c478bd9Sstevel@tonic-gate 				prs_buff("fi");
3667c478bd9Sstevel@tonic-gate 				break;
3677c478bd9Sstevel@tonic-gate 			}
3687c478bd9Sstevel@tonic-gate 
3697c478bd9Sstevel@tonic-gate 			case TSW:
3707c478bd9Sstevel@tonic-gate 				{
371965005c8Schin 					struct regnod 	*swl;
3727c478bd9Sstevel@tonic-gate 
3737c478bd9Sstevel@tonic-gate 					prs_buff("case ");
3747c478bd9Sstevel@tonic-gate 					prs_buff(swptr(t)->swarg);
3757c478bd9Sstevel@tonic-gate 
3767c478bd9Sstevel@tonic-gate 					swl = swptr(t)->swlst;
3777c478bd9Sstevel@tonic-gate 					while(swl)
3787c478bd9Sstevel@tonic-gate 					{
3797c478bd9Sstevel@tonic-gate 						struct argnod	*arg = swl->regptr;
3807c478bd9Sstevel@tonic-gate 
3817c478bd9Sstevel@tonic-gate 						if (arg)
3827c478bd9Sstevel@tonic-gate 						{
3837c478bd9Sstevel@tonic-gate 							prs_buff(arg->argval);
3847c478bd9Sstevel@tonic-gate 							arg = arg->argnxt;
3857c478bd9Sstevel@tonic-gate 						}
3867c478bd9Sstevel@tonic-gate 
3877c478bd9Sstevel@tonic-gate 						while(arg)
3887c478bd9Sstevel@tonic-gate 						{
3897c478bd9Sstevel@tonic-gate 							prs_buff(" | ");
3907c478bd9Sstevel@tonic-gate 							prs_buff(arg->argval);
3917c478bd9Sstevel@tonic-gate 							arg = arg->argnxt;
3927c478bd9Sstevel@tonic-gate 						}
3937c478bd9Sstevel@tonic-gate 
3947c478bd9Sstevel@tonic-gate 						prs_buff(")");
3957c478bd9Sstevel@tonic-gate 						prf(swl->regcom);
3967c478bd9Sstevel@tonic-gate 						prs_buff(";;");
3977c478bd9Sstevel@tonic-gate 						swl = swl->regnxt;
3987c478bd9Sstevel@tonic-gate 					}
3997c478bd9Sstevel@tonic-gate 				}
4007c478bd9Sstevel@tonic-gate 				break;
4017c478bd9Sstevel@tonic-gate 			}
4027c478bd9Sstevel@tonic-gate 		}
4037c478bd9Sstevel@tonic-gate 
4047c478bd9Sstevel@tonic-gate 	sigchk();
4057c478bd9Sstevel@tonic-gate }
4067c478bd9Sstevel@tonic-gate 
407965005c8Schin static void
prarg(struct argnod * argp)408965005c8Schin prarg(struct argnod *argp)
4097c478bd9Sstevel@tonic-gate {
4107c478bd9Sstevel@tonic-gate 	while (argp)
4117c478bd9Sstevel@tonic-gate 	{
4127c478bd9Sstevel@tonic-gate 		prs_buff(argp->argval);
4137c478bd9Sstevel@tonic-gate 		argp=argp->argnxt;
4147c478bd9Sstevel@tonic-gate 		if (argp)
4157c478bd9Sstevel@tonic-gate 			prc_buff(SPACE);
4167c478bd9Sstevel@tonic-gate 	}
4177c478bd9Sstevel@tonic-gate }
4187c478bd9Sstevel@tonic-gate 
419965005c8Schin static void
prio(struct ionod * iop)420965005c8Schin prio(struct ionod *iop)
4217c478bd9Sstevel@tonic-gate {
422965005c8Schin 	int	iof;
423965005c8Schin 	unsigned char	*ion;
4247c478bd9Sstevel@tonic-gate 
4257c478bd9Sstevel@tonic-gate 	while (iop)
4267c478bd9Sstevel@tonic-gate 	{
4277c478bd9Sstevel@tonic-gate 		iof = iop->iofile;
4287c478bd9Sstevel@tonic-gate 		ion = (unsigned char *) iop->ioname;
4297c478bd9Sstevel@tonic-gate 
4307c478bd9Sstevel@tonic-gate 		if (*ion)
4317c478bd9Sstevel@tonic-gate 		{
4327c478bd9Sstevel@tonic-gate 			prc_buff(SPACE);
4337c478bd9Sstevel@tonic-gate 
4347c478bd9Sstevel@tonic-gate 			prn_buff(iof & IOUFD);
4357c478bd9Sstevel@tonic-gate 
4367c478bd9Sstevel@tonic-gate 			if (iof & IODOC)
4377c478bd9Sstevel@tonic-gate 				prs_buff("<<");
4387c478bd9Sstevel@tonic-gate 			else if (iof & IOMOV)
4397c478bd9Sstevel@tonic-gate 			{
4407c478bd9Sstevel@tonic-gate 				if (iof & IOPUT)
4417c478bd9Sstevel@tonic-gate 					prs_buff(">&");
4427c478bd9Sstevel@tonic-gate 				else
4437c478bd9Sstevel@tonic-gate 					prs_buff("<&");
4447c478bd9Sstevel@tonic-gate 
4457c478bd9Sstevel@tonic-gate 			}
4467c478bd9Sstevel@tonic-gate 			else if ((iof & IOPUT) == 0)
4477c478bd9Sstevel@tonic-gate 				prc_buff('<');
4487c478bd9Sstevel@tonic-gate 			else if (iof & IOAPP)
4497c478bd9Sstevel@tonic-gate 				prs_buff(">>");
4507c478bd9Sstevel@tonic-gate 			else
4517c478bd9Sstevel@tonic-gate 				prc_buff('>');
4527c478bd9Sstevel@tonic-gate 
4537c478bd9Sstevel@tonic-gate 			prs_buff(ion);
4547c478bd9Sstevel@tonic-gate 		}
4557c478bd9Sstevel@tonic-gate 		iop = iop->ionxt;
4567c478bd9Sstevel@tonic-gate 	}
4577c478bd9Sstevel@tonic-gate }
458