1 /*********************************************************************** 2 * * 3 * This software is part of the ast package * 4 * Copyright (c) 1982-2009 AT&T Intellectual Property * 5 * and is licensed under the * 6 * Common Public License, Version 1.0 * 7 * by AT&T Intellectual Property * 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_oneoperand[] = "one operand expected"; 54 const char e_formspec[] = "%c: unknown format specifier"; 55 const char e_badregexp[] = "%s: invalid regular expression"; 56 const char e_number[] = "%s: bad number"; 57 const char e_badlocale[] = "%s: unknown locale"; 58 const char e_nullset[] = "%s: parameter null"; 59 const char e_notset[] = "%s: parameter not set"; 60 const char e_noparent[] = "%s: no parent"; 61 const char e_subst[] = "%s: bad substitution"; 62 const char e_create[] = "%s: cannot create"; 63 const char e_tmpcreate[] = "cannot create temporary file"; 64 const char e_restricted[] = "%s: restricted"; 65 const char e_pfsh[] = "%s: disabled in profile shell"; 66 const char e_pexists[] = "process already exists"; 67 const char e_exists[] = "%s: file already exists"; 68 const char e_pipe[] = "cannot create pipe"; 69 const char e_alarm[] = "cannot set alarm"; 70 const char e_open[] = "%s: cannot open"; 71 const char e_notseek[] = "%s: not seekable"; 72 const char e_badseek[] = "%s: invalid seek offset"; 73 const char e_badpattern[] = "%s: invalid shell pattern"; 74 const char e_noread[] = "%s: pattern seek requires read access"; 75 const char e_logout[] = "Use 'exit' to terminate this shell"; 76 const char e_exec[] = "%s: cannot execute"; 77 const char e_pwd[] = "cannot access parent directories"; 78 const char e_found[] = "%s: not found"; 79 const char e_defined[] = "%s: function not defined"; 80 const char e_nointerp[] = "%s: interpreter not found"; 81 const char e_subscript[] = "%s: subscript out of range"; 82 const char e_toodeep[] = "%s: recursion too deep"; 83 const char e_access[] = "permission denied"; 84 #ifdef _cmd_universe 85 const char e_nouniverse[] = "universe not accessible"; 86 #endif /* _cmd_universe */ 87 const char e_direct[] = "bad directory"; 88 const char e_file[] = "%s: bad file unit number"; 89 const char e_redirect[] = "redirection failed"; 90 const char e_trap[] = "%s: bad trap"; 91 const char e_readonly[] = "%s: is read only"; 92 const char e_badfield[] = "%d: negative field size"; 93 const char e_ident[] = "%s: is not an identifier"; 94 const char e_badname[] = "%s: invalid name"; 95 const char e_varname[] = "%s: invalid variable name"; 96 const char e_badfun[] = "%s: invalid function name"; 97 const char e_aliname[] = "%s: invalid alias name"; 98 const char e_badexport[] = "%s: only simple variables can be exported"; 99 const char e_badref[] = "%s: reference variable cannot be an array"; 100 const char e_badsubscript[] = "%c: invalid subscript in assignment"; 101 const char e_noarray[] = "%s: cannot be an array"; 102 const char e_badappend[] = "%s: invalid append to associative array"; 103 const char e_noref[] = "%s: no reference name"; 104 const char e_selfref[] = "%s: invalid self reference"; 105 const char e_globalref[] = "%s: global reference cannot refer to local variable"; 106 const char e_noalias[] = "%s: alias not found\n"; 107 const char e_format[] = "%s: bad format"; 108 const char e_redef[] = "%s: type cannot be redefined"; 109 const char e_required[] = "%s: is a required element of %s"; 110 const char e_badtformat[] = "%c: bad format character in time format"; 111 const char e_nolabels[] = "%s: label not implemented"; 112 const char e_notimp[] = "%s: not implemented"; 113 const char e_notelem[] = "%.*s: is not an element of %s"; 114 const char e_notenum[] = "%s: not an enumeration type"; 115 const char e_unknowntype[] = "%.*s: unknown type"; 116 const char e_nosupport[] = "not supported"; 117 const char e_badrange[] = "%d-%d: invalid range"; 118 const char e_eneedsarg[] = "-e - requires single argument"; 119 const char e_badbase[] = "%s unknown base"; 120 const char e_loop[] = "%s: would cause loop"; 121 const char e_overlimit[] = "%s: limit exceeded"; 122 const char e_badsyntax[] = "incorrect syntax"; 123 const char e_badwrite[] = "write to %d failed"; 124 const char e_on [] = "on"; 125 const char e_off[] = "off"; 126 const char is_reserved[] = " is a keyword"; 127 const char is_builtin[] = " is a shell builtin"; 128 const char is_spcbuiltin[] = " is a special shell builtin"; 129 const char is_builtver[] = "is a shell builtin version of"; 130 const char is_alias[] = "%s is an alias for "; 131 const char is_xalias[] = "%s is an exported alias for "; 132 const char is_talias[] = "is a tracked alias for"; 133 const char is_function[] = " is a function"; 134 const char is_ufunction[] = " is an undefined function"; 135 #ifdef JOBS 136 # ifdef SIGTSTP 137 const char e_newtty[] = "Switching to new tty driver..."; 138 const char e_oldtty[] = "Reverting to old tty driver..."; 139 const char e_no_start[] = "Cannot start job control"; 140 # endif /*SIGTSTP */ 141 const char e_no_jctl[] = "No job control"; 142 const char e_terminate[] = "You have stopped jobs"; 143 const char e_done[] = " Done"; 144 const char e_nlspace[] = "\n "; 145 const char e_running[] = " Running"; 146 const char e_ambiguous[] = "%s: Ambiguous"; 147 const char e_jobsrunning[] = "You have running jobs"; 148 const char e_no_job[] = "no such job"; 149 const char e_no_proc[] = "no such process"; 150 const char e_jobusage[] = "%s: Arguments must be %%job or process ids"; 151 #endif /* JOBS */ 152 const char e_coredump[] = "(coredump)"; 153 const char e_alphanum[] = "[_[:alpha:]]*([_[:alnum:]])"; 154 const char e_devfdNN[] = "/dev/fd/+([0-9])"; 155 const char e_devfdstd[] = "/dev/@(fd/+([0-9])|std@(in|out|err))"; 156 const char e_signo[] = "Signal %d"; 157 #if SHOPT_FS_3D 158 const char e_cantget[] = "cannot get %s"; 159 const char e_cantset[] = "cannot set %s"; 160 const char e_mapping[] = "mapping"; 161 const char e_versions[] = "versions"; 162 #endif /* SHOPT_FS_3D */ 163 164 /* string constants */ 165 const char e_heading[] = "Current option settings"; 166 const char e_sptbnl[] = " \t\n"; 167 const char e_defpath[] = "/bin:/usr/bin:"; 168 const char e_defedit[] = "/bin/ed"; 169 const char e_unknown [] = "<command unknown>"; 170 const char e_devnull[] = "/dev/null"; 171 const char e_traceprompt[] = "+ "; 172 const char e_supprompt[] = "# "; 173 const char e_stdprompt[] = "$ "; 174 const char e_profile[] = "$HOME/.profile"; 175 const char e_sysprofile[] = "/etc/profile"; 176 const char e_suidprofile[] = "/etc/suid_profile"; 177 #if SHOPT_SYSRC 178 const char e_sysrc[] = "/etc/ksh.kshrc"; 179 #endif 180 #if SHOPT_BASH 181 #if SHOPT_SYSRC 182 const char e_bash_sysrc[] = "/etc/bash.bashrc"; 183 #endif 184 const char e_bash_rc[] = "$HOME/.bashrc"; 185 const char e_bash_login[] = "$HOME/.bash_login"; 186 const char e_bash_logout[] = "$HOME/.bash_logout"; 187 const char e_bash_profile[] = "$HOME/.bash_profile"; 188 #endif 189 const char e_crondir[] = "/usr/spool/cron/atjobs"; 190 const char e_prohibited[] = "login setuid/setgid shells prohibited"; 191 #if SHOPT_SUID_EXEC 192 const char e_suidexec[] = "/etc/suid_exec"; 193 #endif /* SHOPT_SUID_EXEC */ 194 const char hist_fname[] = "/.sh_history"; 195 const char e_dot[] = "."; 196 const char e_envmarker[] = "A__z"; 197 const char e_timeformat[] = "\nreal\t%2lR\nuser\t%2lU\nsys\t%2lS"; 198 const char e_dict[] = "libshell"; 199