1146572Sharti/*-
2146572Sharti * Copyright (c) 1988, 1989, 1990, 1993
3146572Sharti *	The Regents of the University of California.  All rights reserved.
4146572Sharti * Copyright (c) 1988, 1989 by Adam de Boor
5146572Sharti * Copyright (c) 1989 by Berkeley Softworks
6146572Sharti * All rights reserved.
7146572Sharti *
8146572Sharti * This code is derived from software contributed to Berkeley by
9146572Sharti * Adam de Boor.
10146572Sharti *
11146572Sharti * Redistribution and use in source and binary forms, with or without
12146572Sharti * modification, are permitted provided that the following conditions
13146572Sharti * are met:
14146572Sharti * 1. Redistributions of source code must retain the above copyright
15146572Sharti *    notice, this list of conditions and the following disclaimer.
16146572Sharti * 2. Redistributions in binary form must reproduce the above copyright
17146572Sharti *    notice, this list of conditions and the following disclaimer in the
18146572Sharti *    documentation and/or other materials provided with the distribution.
19146572Sharti * 3. All advertising materials mentioning features or use of this software
20146572Sharti *    must display the following acknowledgement:
21146572Sharti *	This product includes software developed by the University of
22146572Sharti *	California, Berkeley and its contributors.
23146572Sharti * 4. Neither the name of the University nor the names of its contributors
24146572Sharti *    may be used to endorse or promote products derived from this software
25146572Sharti *    without specific prior written permission.
26146572Sharti *
27146572Sharti * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28146572Sharti * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29146572Sharti * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30146572Sharti * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31146572Sharti * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32146572Sharti * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33146572Sharti * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34146572Sharti * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35146572Sharti * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36146572Sharti * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37146572Sharti * SUCH DAMAGE.
38146572Sharti *
39146572Sharti * $FreeBSD$
40146572Sharti */
41146572Sharti
42146572Sharti#ifndef shell_h_6002e3b8
43146572Sharti#define	shell_h_6002e3b8
44146572Sharti
45146572Sharti#include <sys/queue.h>
46146572Sharti
47146572Sharti#include "str.h"
48146572Sharti#include "util.h"
49146572Sharti
50146572Sharti/**
51146572Sharti * Shell Specifications:
52146572Sharti *
53146572Sharti * Some special stuff goes on if a shell doesn't have error control. In such
54146572Sharti * a case, errCheck becomes a printf template for echoing the command,
55146572Sharti * should echoing be on and ignErr becomes another printf template for
56146572Sharti * executing the command while ignoring the return status. If either of these
57146572Sharti * strings is empty when hasErrCtl is FALSE, the command will be executed
58146572Sharti * anyway as is and if it causes an error, so be it.
59146572Sharti */
60146572Shartistruct Shell {
61146572Sharti	TAILQ_ENTRY(Shell) link;	/* link all shell descriptions */
62146572Sharti
63146572Sharti	/*
64146572Sharti	 * the name of the shell. For Bourne and C shells, this is used
65146572Sharti	 * only to find the shell description when used as the single
66146572Sharti	 * source of a .SHELL target.
67146572Sharti	 */
68146572Sharti	char	*name;
69146572Sharti
70146572Sharti	char	*path;		/* full path to the shell */
71146572Sharti
72146572Sharti	/* True if both echoOff and echoOn defined */
73146572Sharti	Boolean	hasEchoCtl;
74146572Sharti
75146572Sharti	char	*echoOff;	/* command to turn off echo */
76146572Sharti	char	*echoOn;	/* command to turn it back on */
77146572Sharti
78146572Sharti	/*
79146572Sharti	 * What the shell prints, and its length, when given the
80146572Sharti	 * echo-off command. This line will not be printed when
81146572Sharti	 * received from the shell. This is usually the command which
82146572Sharti	 * was executed to turn off echoing
83146572Sharti	 */
84146572Sharti	char	*noPrint;
85146572Sharti
86146572Sharti	/* set if can control error checking for individual commands */
87146572Sharti	Boolean	hasErrCtl;
88146572Sharti
89146572Sharti	/* string to turn error checking on */
90146572Sharti	char	*errCheck;
91146572Sharti
92146572Sharti	/* string to turn off error checking */
93146572Sharti	char	*ignErr;
94146572Sharti
95146572Sharti	char	*echo;	/* command line flag: echo commands */
96146572Sharti	char	*exit;	/* command line flag: exit on error */
97146572Sharti
98146572Sharti	ArgArray builtins;	/* ordered list of shell builtins */
99146572Sharti	char	*meta;		/* shell meta characters */
100146572Sharti
101146572Sharti	Boolean	unsetenv;	/* unsetenv("ENV") before exec */
102146572Sharti};
103146572ShartiTAILQ_HEAD(Shells, Shell);
104146572Sharti
105146572Shartiextern struct Shell		*commandShell;
106146572Sharti
107146572Shartivoid				Shell_Init(void);
108146572ShartiBoolean				Shell_Parse(const char []);
109146572Sharti
110146572Sharti#endif /* shell_h_6002e3b8 */
111