1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 23*0Sstevel@tonic-gate /* All Rights Reserved */ 24*0Sstevel@tonic-gate 25*0Sstevel@tonic-gate 26*0Sstevel@tonic-gate /* 27*0Sstevel@tonic-gate * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 28*0Sstevel@tonic-gate * Use is subject to license terms. 29*0Sstevel@tonic-gate */ 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 32*0Sstevel@tonic-gate /* 33*0Sstevel@tonic-gate * UNIX shell 34*0Sstevel@tonic-gate */ 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gate #include "defs.h" 38*0Sstevel@tonic-gate #include "sym.h" 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate /* 41*0Sstevel@tonic-gate * error messages 42*0Sstevel@tonic-gate */ 43*0Sstevel@tonic-gate #ifndef __STDC__ 44*0Sstevel@tonic-gate #define const 45*0Sstevel@tonic-gate #endif 46*0Sstevel@tonic-gate 47*0Sstevel@tonic-gate const char badopt[] = "bad option(s)"; 48*0Sstevel@tonic-gate const char mailmsg[] = "you have mail\n"; 49*0Sstevel@tonic-gate const char nospace[] = "no space"; 50*0Sstevel@tonic-gate const char nostack[] = "no stack space"; 51*0Sstevel@tonic-gate const char synmsg[] = "syntax error"; 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gate const char badnum[] = "bad number"; 54*0Sstevel@tonic-gate const char badsig[] = "bad signal"; 55*0Sstevel@tonic-gate const char badid[] = "invalid id"; 56*0Sstevel@tonic-gate const char badparam[] = "parameter null or not set"; 57*0Sstevel@tonic-gate const char unset[] = "parameter not set"; 58*0Sstevel@tonic-gate const char badsub[] = "bad substitution"; 59*0Sstevel@tonic-gate const char badcreate[] = "cannot create"; 60*0Sstevel@tonic-gate const char nofork[] = "fork failed - too many processes"; 61*0Sstevel@tonic-gate const char noswap[] = "cannot fork: no swap space"; 62*0Sstevel@tonic-gate const char restricted[] = "restricted"; 63*0Sstevel@tonic-gate const char piperr[] = "cannot make pipe"; 64*0Sstevel@tonic-gate const char badopen[] = "cannot open"; 65*0Sstevel@tonic-gate const char coredump[] = " - core dumped"; 66*0Sstevel@tonic-gate const char arglist[] = "arg list too long"; 67*0Sstevel@tonic-gate const char txtbsy[] = "text busy"; 68*0Sstevel@tonic-gate const char toobig[] = "too big"; 69*0Sstevel@tonic-gate const char badexec[] = "cannot execute"; 70*0Sstevel@tonic-gate const char notfound[] = "not found"; 71*0Sstevel@tonic-gate const char badfile[] = "bad file number"; 72*0Sstevel@tonic-gate const char badshift[] = "cannot shift"; 73*0Sstevel@tonic-gate const char baddir[] = "bad directory"; 74*0Sstevel@tonic-gate const char badtrap[] = "bad trap"; 75*0Sstevel@tonic-gate const char wtfailed[] = "is read only"; 76*0Sstevel@tonic-gate const char notid[] = "is not an identifier"; 77*0Sstevel@tonic-gate const char badulimit[] = "bad ulimit"; 78*0Sstevel@tonic-gate const char badresource[] = "no such resource"; 79*0Sstevel@tonic-gate const char badreturn[] = "cannot return when not in function"; 80*0Sstevel@tonic-gate const char badexport[] = "cannot export functions"; 81*0Sstevel@tonic-gate const char badunset[] = "cannot unset"; 82*0Sstevel@tonic-gate const char nohome[] = "no home directory"; 83*0Sstevel@tonic-gate const char badperm[] = "execute permission denied"; 84*0Sstevel@tonic-gate const char longpwd[] = "sh error: pwd too long"; 85*0Sstevel@tonic-gate const char mssgargn[] = "missing arguments"; 86*0Sstevel@tonic-gate const char libacc[] = "can't access a needed shared library"; 87*0Sstevel@tonic-gate const char libbad[] = "accessing a corrupted shared library"; 88*0Sstevel@tonic-gate const char libscn[] = ".lib section in a.out corrupted"; 89*0Sstevel@tonic-gate const char libmax[] = "attempting to link in too many libs"; 90*0Sstevel@tonic-gate const char emultihop[] = "Multihop attempted"; 91*0Sstevel@tonic-gate const char nulldir[] = "null directory"; 92*0Sstevel@tonic-gate const char enotdir[] = "not a directory"; 93*0Sstevel@tonic-gate const char enoent[] = "does not exist"; 94*0Sstevel@tonic-gate const char eacces[] = "permission denied"; 95*0Sstevel@tonic-gate const char enolink[] = "remote link inactive"; 96*0Sstevel@tonic-gate const char badscale[] = "bad scaling"; 97*0Sstevel@tonic-gate const char exited[] = "Done"; 98*0Sstevel@tonic-gate const char running[] = "Running"; 99*0Sstevel@tonic-gate const char ambiguous[] = "ambiguous"; 100*0Sstevel@tonic-gate const char usage[] = "usage"; 101*0Sstevel@tonic-gate const char nojc[] = "no job control"; 102*0Sstevel@tonic-gate const char stopuse[] = "stop id ..."; 103*0Sstevel@tonic-gate const char ulimuse[] = "ulimit [ -HSacdfnstv ] [ limit ]"; 104*0Sstevel@tonic-gate const char killuse[] = "kill [ [ -sig ] id ... | -l ]"; 105*0Sstevel@tonic-gate const char jobsuse[] = "jobs [ [ -l | -p ] [ id ... ] | -x cmd ]"; 106*0Sstevel@tonic-gate const char nosuchjob[] = "no such job"; 107*0Sstevel@tonic-gate const char nosuchpid[] = "no such process"; 108*0Sstevel@tonic-gate const char nosuchpgid[] = "no such process group"; 109*0Sstevel@tonic-gate const char nocurjob[] = "no current job"; 110*0Sstevel@tonic-gate const char jobsstopped[] = "there are stopped jobs"; 111*0Sstevel@tonic-gate const char jobsrunning[] = "there are running jobs"; 112*0Sstevel@tonic-gate const char loginsh[] = "cannot stop login shell"; 113*0Sstevel@tonic-gate 114*0Sstevel@tonic-gate /* 115*0Sstevel@tonic-gate * messages for 'builtin' functions 116*0Sstevel@tonic-gate */ 117*0Sstevel@tonic-gate const char btest[] = "test"; 118*0Sstevel@tonic-gate const char badop[] = "unknown operator "; 119*0Sstevel@tonic-gate /* 120*0Sstevel@tonic-gate * built in names 121*0Sstevel@tonic-gate */ 122*0Sstevel@tonic-gate const char pathname[] = "PATH"; 123*0Sstevel@tonic-gate const char cdpname[] = "CDPATH"; 124*0Sstevel@tonic-gate const char homename[] = "HOME"; 125*0Sstevel@tonic-gate const char mailname[] = "MAIL"; 126*0Sstevel@tonic-gate const char ifsname[] = "IFS"; 127*0Sstevel@tonic-gate const char ps1name[] = "PS1"; 128*0Sstevel@tonic-gate const char ps2name[] = "PS2"; 129*0Sstevel@tonic-gate const char mchkname[] = "MAILCHECK"; 130*0Sstevel@tonic-gate const char acctname[] = "SHACCT"; 131*0Sstevel@tonic-gate const char mailpname[] = "MAILPATH"; 132*0Sstevel@tonic-gate 133*0Sstevel@tonic-gate /* 134*0Sstevel@tonic-gate * string constants 135*0Sstevel@tonic-gate */ 136*0Sstevel@tonic-gate const char nullstr[] = ""; 137*0Sstevel@tonic-gate const char sptbnl[] = " \t\n"; 138*0Sstevel@tonic-gate const char defpath[] = "/usr/bin:"; 139*0Sstevel@tonic-gate const char colon[] = ": "; 140*0Sstevel@tonic-gate const char minus[] = "-"; 141*0Sstevel@tonic-gate const char endoffile[] = "end of file"; 142*0Sstevel@tonic-gate const char unexpected[] = " unexpected"; 143*0Sstevel@tonic-gate const char atline[] = " at line "; 144*0Sstevel@tonic-gate const char devnull[] = "/dev/null"; 145*0Sstevel@tonic-gate const char execpmsg[] = "+ "; 146*0Sstevel@tonic-gate const char readmsg[] = "> "; 147*0Sstevel@tonic-gate const char stdprompt[] = "$ "; 148*0Sstevel@tonic-gate const char supprompt[] = "# "; 149*0Sstevel@tonic-gate const char profile[] = ".profile"; 150*0Sstevel@tonic-gate const char sysprofile[] = "/etc/profile"; 151*0Sstevel@tonic-gate 152*0Sstevel@tonic-gate /* 153*0Sstevel@tonic-gate * locale testing 154*0Sstevel@tonic-gate */ 155*0Sstevel@tonic-gate const char localedir[] = "/usr/lib/locale"; 156*0Sstevel@tonic-gate int localedir_exists; 157*0Sstevel@tonic-gate 158*0Sstevel@tonic-gate /* 159*0Sstevel@tonic-gate * tables 160*0Sstevel@tonic-gate */ 161*0Sstevel@tonic-gate 162*0Sstevel@tonic-gate const struct sysnod reserved[] = 163*0Sstevel@tonic-gate { 164*0Sstevel@tonic-gate { "case", CASYM }, 165*0Sstevel@tonic-gate { "do", DOSYM }, 166*0Sstevel@tonic-gate { "done", ODSYM }, 167*0Sstevel@tonic-gate { "elif", EFSYM }, 168*0Sstevel@tonic-gate { "else", ELSYM }, 169*0Sstevel@tonic-gate { "esac", ESSYM }, 170*0Sstevel@tonic-gate { "fi", FISYM }, 171*0Sstevel@tonic-gate { "for", FORSYM }, 172*0Sstevel@tonic-gate { "if", IFSYM }, 173*0Sstevel@tonic-gate { "in", INSYM }, 174*0Sstevel@tonic-gate { "then", THSYM }, 175*0Sstevel@tonic-gate { "until", UNSYM }, 176*0Sstevel@tonic-gate { "while", WHSYM }, 177*0Sstevel@tonic-gate { "{", BRSYM }, 178*0Sstevel@tonic-gate { "}", KTSYM } 179*0Sstevel@tonic-gate }; 180*0Sstevel@tonic-gate 181*0Sstevel@tonic-gate const int no_reserved = sizeof(reserved)/sizeof(struct sysnod); 182*0Sstevel@tonic-gate 183*0Sstevel@tonic-gate const char *sysmsg[] = 184*0Sstevel@tonic-gate { 185*0Sstevel@tonic-gate 0, 186*0Sstevel@tonic-gate "Hangup", 187*0Sstevel@tonic-gate 0, /* Interrupt */ 188*0Sstevel@tonic-gate "Quit", 189*0Sstevel@tonic-gate "Illegal instruction", 190*0Sstevel@tonic-gate "Trace/BPT trap", 191*0Sstevel@tonic-gate "abort", 192*0Sstevel@tonic-gate "EMT trap", 193*0Sstevel@tonic-gate "Floating exception", 194*0Sstevel@tonic-gate "Killed", 195*0Sstevel@tonic-gate "Bus error", 196*0Sstevel@tonic-gate "Memory fault", 197*0Sstevel@tonic-gate "Bad system call", 198*0Sstevel@tonic-gate 0, /* Broken pipe */ 199*0Sstevel@tonic-gate "Alarm call", 200*0Sstevel@tonic-gate "Terminated", 201*0Sstevel@tonic-gate "Signal 16", 202*0Sstevel@tonic-gate "Signal 17", 203*0Sstevel@tonic-gate "Child death", 204*0Sstevel@tonic-gate "Power Fail" 205*0Sstevel@tonic-gate }; 206*0Sstevel@tonic-gate 207*0Sstevel@tonic-gate const char export[] = "export"; 208*0Sstevel@tonic-gate const char duperr[] = "cannot dup"; 209*0Sstevel@tonic-gate const char readonly[] = "readonly"; 210*0Sstevel@tonic-gate 211*0Sstevel@tonic-gate 212*0Sstevel@tonic-gate const struct sysnod commands[] = 213*0Sstevel@tonic-gate { 214*0Sstevel@tonic-gate { ".", SYSDOT }, 215*0Sstevel@tonic-gate { ":", SYSNULL }, 216*0Sstevel@tonic-gate 217*0Sstevel@tonic-gate #ifndef RES 218*0Sstevel@tonic-gate { "[", SYSTST }, 219*0Sstevel@tonic-gate #endif 220*0Sstevel@tonic-gate { "bg", SYSFGBG }, 221*0Sstevel@tonic-gate { "break", SYSBREAK }, 222*0Sstevel@tonic-gate { "cd", SYSCD }, 223*0Sstevel@tonic-gate { "chdir", SYSCD }, 224*0Sstevel@tonic-gate { "continue", SYSCONT }, 225*0Sstevel@tonic-gate { "echo", SYSECHO }, 226*0Sstevel@tonic-gate { "eval", SYSEVAL }, 227*0Sstevel@tonic-gate { "exec", SYSEXEC }, 228*0Sstevel@tonic-gate { "exit", SYSEXIT }, 229*0Sstevel@tonic-gate { "export", SYSXPORT }, 230*0Sstevel@tonic-gate { "fg", SYSFGBG }, 231*0Sstevel@tonic-gate { "getopts", SYSGETOPT }, 232*0Sstevel@tonic-gate { "hash", SYSHASH }, 233*0Sstevel@tonic-gate { "jobs", SYSJOBS }, 234*0Sstevel@tonic-gate { "kill", SYSKILL }, 235*0Sstevel@tonic-gate #ifdef RES 236*0Sstevel@tonic-gate { "login", SYSLOGIN }, 237*0Sstevel@tonic-gate { "newgrp", SYSLOGIN }, 238*0Sstevel@tonic-gate #else 239*0Sstevel@tonic-gate { "newgrp", SYSNEWGRP }, 240*0Sstevel@tonic-gate #endif 241*0Sstevel@tonic-gate 242*0Sstevel@tonic-gate { "pwd", SYSPWD }, 243*0Sstevel@tonic-gate { "read", SYSREAD }, 244*0Sstevel@tonic-gate { "readonly", SYSRDONLY }, 245*0Sstevel@tonic-gate { "return", SYSRETURN }, 246*0Sstevel@tonic-gate { "set", SYSSET }, 247*0Sstevel@tonic-gate { "shift", SYSSHFT }, 248*0Sstevel@tonic-gate { "stop", SYSSTOP }, 249*0Sstevel@tonic-gate { "suspend", SYSSUSP}, 250*0Sstevel@tonic-gate { "test", SYSTST }, 251*0Sstevel@tonic-gate { "times", SYSTIMES }, 252*0Sstevel@tonic-gate { "trap", SYSTRAP }, 253*0Sstevel@tonic-gate { "type", SYSTYPE }, 254*0Sstevel@tonic-gate 255*0Sstevel@tonic-gate 256*0Sstevel@tonic-gate #ifndef RES 257*0Sstevel@tonic-gate { "ulimit", SYSULIMIT }, 258*0Sstevel@tonic-gate { "umask", SYSUMASK }, 259*0Sstevel@tonic-gate #endif 260*0Sstevel@tonic-gate 261*0Sstevel@tonic-gate { "unset", SYSUNS }, 262*0Sstevel@tonic-gate { "wait", SYSWAIT } 263*0Sstevel@tonic-gate }; 264*0Sstevel@tonic-gate 265*0Sstevel@tonic-gate const int no_commands = sizeof(commands)/sizeof(struct sysnod); 266*0Sstevel@tonic-gate 267