1 /*********************************************************************** 2 * * 3 * This software is part of the ast package * 4 * Copyright (c) 1982-2007 AT&T Knowledge Ventures * 5 * and is licensed under the * 6 * Common Public License, Version 1.0 * 7 * by AT&T Knowledge Ventures * 8 * * 9 * A copy of the License is available at * 10 * http://www.opensource.org/licenses/cpl1.0.txt * 11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 12 * * 13 * Information and Software Systems Research * 14 * AT&T Research * 15 * Florham Park NJ * 16 * * 17 * David Korn <dgk@research.att.com> * 18 * * 19 ***********************************************************************/ 20 #pragma prototyped 21 /* 22 * UNIX shell 23 * S. R. Bourne 24 * Rewritten by David Korn 25 * 26 * AT&T Labs 27 * 28 */ 29 30 #include <ast.h> 31 #include <errno.h> 32 #include "defs.h" 33 #include "path.h" 34 #include "io.h" 35 #include "shlex.h" 36 #include "timeout.h" 37 #include "history.h" 38 #include "builtins.h" 39 #include "jobs.h" 40 #include "edit.h" 41 42 /* error messages */ 43 const char e_timewarn[] = "\r\n\ashell will timeout in 60 seconds due to inactivity"; 44 const char e_runvi[] = "\\hist -e \"${VISUAL:-${EDITOR:-vi}}\" "; 45 const char e_timeout[] = "timed out waiting for input"; 46 const char e_mailmsg[] = "you have mail in $_"; 47 const char e_query[] = "no query process"; 48 const char e_history[] = "no history file"; 49 const char e_histopen[] = "history file cannot open"; 50 const char e_option[] = "%s: bad option(s)"; 51 const char e_toomany[] = "open file limit exceeded"; 52 const char e_argtype[] = "invalid argument of type %c"; 53 const char e_formspec[] = "%c: unknown format specifier"; 54 const char e_badregexp[] = "%s: invalid regular expression"; 55 const char e_number[] = "%s: bad number"; 56 const char e_badlocale[] = "%s: unknown locale"; 57 const char e_nullset[] = "%s: parameter null"; 58 const char e_notset[] = "%s: parameter not set"; 59 const char e_noparent[] = "%s: no parent"; 60 const char e_subst[] = "%s: bad substitution"; 61 const char e_create[] = "%s: cannot create"; 62 const char e_tmpcreate[] = "cannot create temporary file"; 63 const char e_restricted[] = "%s: restricted"; 64 const char e_pfsh[] = "%s: disabled in profile shell"; 65 const char e_pexists[] = "process already exists"; 66 const char e_exists[] = "%s: file already exists"; 67 const char e_pipe[] = "cannot create pipe"; 68 const char e_alarm[] = "cannot set alarm"; 69 const char e_open[] = "%s: cannot open"; 70 const char e_notseek[] = "%s: not seekable"; 71 const char e_badseek[] = "%s: invalid seek offset"; 72 const char e_badpattern[] = "%s: invalid shell pattern"; 73 const char e_noread[] = "%s: pattern seek requires read access"; 74 const char e_logout[] = "Use 'exit' to terminate this shell"; 75 const char e_exec[] = "%s: cannot execute"; 76 const char e_pwd[] = "cannot access parent directories"; 77 const char e_found[] = "%s: not found"; 78 const char e_defined[] = "%s: function not defined"; 79 const char e_nointerp[] = "%s: interpreter not found"; 80 const char e_subscript[] = "%s: subscript out of range"; 81 const char e_toodeep[] = "%s: recursion too deep"; 82 const char e_access[] = "permission denied"; 83 #ifdef _cmd_universe 84 const char e_nouniverse[] = "universe not accessible"; 85 #endif /* _cmd_universe */ 86 const char e_direct[] = "bad directory"; 87 const char e_file[] = "%s: bad file unit number"; 88 const char e_trap[] = "%s: bad trap"; 89 const char e_readonly[] = "%s: is read only"; 90 const char e_badfield[] = "%d: negative field size"; 91 const char e_ident[] = "%s: is not an identifier"; 92 const char e_badname[] = "%s: invalid name"; 93 const char e_varname[] = "%s: invalid variable name"; 94 const char e_badfun[] = "%s: invalid function name"; 95 const char e_aliname[] = "%s: invalid alias name"; 96 const char e_badexport[] = "%s: invalid export name"; 97 const char e_badref[] = "%s: reference variable cannot be an array"; 98 const char e_noarray[] = "%s: cannot be an array"; 99 const char e_noref[] = "%s: no reference name"; 100 const char e_selfref[] = "%s: invalid self reference"; 101 const char e_noalias[] = "%s: alias not found\n"; 102 const char e_format[] = "%s: bad format"; 103 const char e_redef[] = "%s: type cannot be redefined"; 104 const char e_badtformat[] = "%c: bad format character in time format"; 105 const char e_nolabels[] = "%s: label not implemented"; 106 const char e_notimp[] = "%s: not implemented"; 107 const char e_nosupport[] = "not supported"; 108 const char e_badrange[] = "%d-%d: invalid range"; 109 const char e_eneedsarg[] = "-e - requires single argument"; 110 const char e_badbase[] = "%s unknown base"; 111 const char e_loop[] = "%s: would cause loop"; 112 const char e_overlimit[] = "%s: limit exceeded"; 113 const char e_badsyntax[] = "incorrect syntax"; 114 const char e_badwrite[] = "write to %d failed"; 115 const char e_on [] = "on"; 116 const char e_off[] = "off"; 117 const char is_reserved[] = " is a keyword"; 118 const char is_builtin[] = " is a shell builtin"; 119 const char is_builtver[] = "is a shell builtin version of"; 120 const char is_alias[] = "%s is an alias for "; 121 const char is_xalias[] = "%s is an exported alias for "; 122 const char is_talias[] = "is a tracked alias for"; 123 const char is_function[] = " is a function"; 124 const char is_ufunction[] = " is an undefined function"; 125 #ifdef JOBS 126 # ifdef SIGTSTP 127 const char e_newtty[] = "Switching to new tty driver..."; 128 const char e_oldtty[] = "Reverting to old tty driver..."; 129 const char e_no_start[] = "Cannot start job control"; 130 # endif /*SIGTSTP */ 131 const char e_no_jctl[] = "No job control"; 132 const char e_terminate[] = "You have stopped jobs"; 133 const char e_done[] = " Done"; 134 const char e_nlspace[] = "\n "; 135 const char e_running[] = " Running"; 136 const char e_ambiguous[] = "%s: Ambiguous"; 137 const char e_jobsrunning[] = "You have running jobs"; 138 const char e_no_job[] = "no such job"; 139 const char e_no_proc[] = "no such process"; 140 const char e_jobusage[] = "%s: Arguments must be %%job or process ids"; 141 #endif /* JOBS */ 142 const char e_coredump[] = "(coredump)"; 143 const char e_alphanum[] = "[_[:alpha:]]*([_[:alnum:]])"; 144 const char e_devfdNN[] = "/dev/fd/+([0-9])"; 145 const char e_devfdstd[] = "/dev/@(fd/+([0-9])|std@(in|out|err))"; 146 const char e_signo[] = "Signal %d"; 147 #if SHOPT_FS_3D 148 const char e_cantget[] = "cannot get %s"; 149 const char e_cantset[] = "cannot set %s"; 150 const char e_mapping[] = "mapping"; 151 const char e_versions[] = "versions"; 152 #endif /* SHOPT_FS_3D */ 153 154 /* string constants */ 155 const char e_heading[] = "Current option settings"; 156 const char e_sptbnl[] = " \t\n"; 157 const char e_defpath[] = "/bin:/usr/bin:"; 158 const char e_defedit[] = "/bin/ed"; 159 const char e_unknown [] = "<command unknown>"; 160 const char e_devnull[] = "/dev/null"; 161 const char e_traceprompt[] = "+ "; 162 const char e_supprompt[] = "# "; 163 const char e_stdprompt[] = "$ "; 164 const char e_profile[] = "$HOME/.profile"; 165 const char e_sysprofile[] = "/etc/profile"; 166 const char e_suidprofile[] = "/etc/suid_profile"; 167 #if SHOPT_SYSRC 168 const char e_sysrc[] = "/etc/ksh.kshrc"; 169 #endif 170 #if SHOPT_BASH 171 #if SHOPT_SYSRC 172 const char e_bash_sysrc[] = "/etc/bash.bashrc"; 173 #endif 174 const char e_bash_rc[] = "$HOME/.bashrc"; 175 const char e_bash_login[] = "$HOME/.bash_login"; 176 const char e_bash_logout[] = "$HOME/.bash_logout"; 177 const char e_bash_profile[] = "$HOME/.bash_profile"; 178 #endif 179 const char e_crondir[] = "/usr/spool/cron/atjobs"; 180 const char e_prohibited[] = "login setuid/setgid shells prohibited"; 181 #if SHOPT_SUID_EXEC 182 const char e_suidexec[] = "/etc/suid_exec"; 183 #endif /* SHOPT_SUID_EXEC */ 184 const char hist_fname[] = "/.sh_history"; 185 const char e_dot[] = "."; 186 const char e_envmarker[] = "A__z"; 187 const char e_timeformat[] = "\nreal\t%2lR\nuser\t%2lU\nsys\t%2lS"; 188 const char e_dict[] = "libshell"; 189