1 /*- 2 * Copyright (c) 1980, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * This product includes software developed by the University of 16 * California, Berkeley and its contributors. 17 * 4. Neither the name of the University nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34 #ifndef lint 35 /*static char sccsid[] = "from: @(#)init.c 8.1 (Berkeley) 5/31/93";*/ 36 static char *rcsid = "$Id: init.c,v 1.5 1994/09/21 00:10:59 mycroft Exp $"; 37 #endif /* not lint */ 38 39 #if __STDC__ 40 # include <stdarg.h> 41 #else 42 # include <varargs.h> 43 #endif 44 45 #include "csh.h" 46 #include "extern.h" 47 48 #define INF 1000 49 50 struct biltins bfunc[] = 51 { 52 { "@", dolet, 0, INF }, 53 { "alias", doalias, 0, INF }, 54 { "alloc", showall, 0, 1 }, 55 { "bg", dobg, 0, INF }, 56 { "break", dobreak, 0, 0 }, 57 { "breaksw", doswbrk, 0, 0 }, 58 { "case", dozip, 0, 1 }, 59 { "cd", dochngd, 0, INF }, 60 { "chdir", dochngd, 0, INF }, 61 { "continue", docontin, 0, 0 }, 62 { "default", dozip, 0, 0 }, 63 { "dirs", dodirs, 0, INF }, 64 { "echo", doecho, 0, INF }, 65 { "else", doelse, 0, INF }, 66 { "end", doend, 0, 0 }, 67 { "endif", dozip, 0, 0 }, 68 { "endsw", dozip, 0, 0 }, 69 { "eval", doeval, 0, INF }, 70 { "exec", execash, 1, INF }, 71 { "exit", doexit, 0, INF }, 72 { "fg", dofg, 0, INF }, 73 { "foreach", doforeach, 3, INF }, 74 { "glob", doglob, 0, INF }, 75 { "goto", dogoto, 1, 1 }, 76 { "hashstat", hashstat, 0, 0 }, 77 { "history", dohist, 0, 2 }, 78 { "if", doif, 1, INF }, 79 { "jobs", dojobs, 0, 1 }, 80 { "kill", dokill, 1, INF }, 81 { "limit", dolimit, 0, 3 }, 82 { "linedit", doecho, 0, INF }, 83 { "login", dologin, 0, 1 }, 84 { "logout", dologout, 0, 0 }, 85 { "nice", donice, 0, INF }, 86 { "nohup", donohup, 0, INF }, 87 { "notify", donotify, 0, INF }, 88 { "onintr", doonintr, 0, 2 }, 89 { "popd", dopopd, 0, INF }, 90 { "printf", doprintf, 1, INF }, 91 { "pushd", dopushd, 0, INF }, 92 { "rehash", dohash, 0, 0 }, 93 { "repeat", dorepeat, 2, INF }, 94 { "set", doset, 0, INF }, 95 { "setenv", dosetenv, 0, 2 }, 96 { "shift", shift, 0, 1 }, 97 { "source", dosource, 1, 2 }, 98 { "stop", dostop, 1, INF }, 99 { "suspend", dosuspend, 0, 0 }, 100 { "switch", doswitch, 1, INF }, 101 { "time", dotime, 0, INF }, 102 { "umask", doumask, 0, 1 }, 103 { "unalias", unalias, 1, INF }, 104 { "unhash", dounhash, 0, 0 }, 105 { "unlimit", dounlimit, 0, INF }, 106 { "unset", unset, 1, INF }, 107 { "unsetenv", dounsetenv, 1, INF }, 108 { "wait", dowait, 0, 0 }, 109 { "which", dowhich, 1, INF }, 110 { "while", dowhile, 1, INF } 111 }; 112 int nbfunc = sizeof bfunc / sizeof *bfunc; 113 114 struct srch srchn[] = 115 { 116 { "@", T_LET }, 117 { "break", T_BREAK }, 118 { "breaksw", T_BRKSW }, 119 { "case", T_CASE }, 120 { "default", T_DEFAULT }, 121 { "else", T_ELSE }, 122 { "end", T_END }, 123 { "endif", T_ENDIF }, 124 { "endsw", T_ENDSW }, 125 { "exit", T_EXIT }, 126 { "foreach", T_FOREACH }, 127 { "goto", T_GOTO }, 128 { "if", T_IF }, 129 { "label", T_LABEL }, 130 { "set", T_SET }, 131 { "switch", T_SWITCH }, 132 { "while", T_WHILE } 133 }; 134 int nsrchn = sizeof srchn / sizeof *srchn; 135 136