14887Schin /*********************************************************************** 24887Schin * * 34887Schin * This software is part of the ast package * 4*12068SRoger.Faulkner@Oracle.COM * Copyright (c) 1982-2010 AT&T Intellectual Property * 54887Schin * and is licensed under the * 64887Schin * Common Public License, Version 1.0 * 78462SApril.Chin@Sun.COM * by AT&T Intellectual Property * 84887Schin * * 94887Schin * A copy of the License is available at * 104887Schin * http://www.opensource.org/licenses/cpl1.0.txt * 114887Schin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 124887Schin * * 134887Schin * Information and Software Systems Research * 144887Schin * AT&T Research * 154887Schin * Florham Park NJ * 164887Schin * * 174887Schin * David Korn <dgk@research.att.com> * 184887Schin * * 194887Schin ***********************************************************************/ 204887Schin #pragma prototyped 214887Schin /* 224887Schin * UNIX shell 234887Schin * S. R. Bourne 244887Schin * Rewritten by David Korn 254887Schin * 264887Schin * AT&T Labs 274887Schin * 284887Schin */ 294887Schin 304887Schin #include <ast.h> 314887Schin #include <errno.h> 324887Schin #include "defs.h" 334887Schin #include "path.h" 344887Schin #include "io.h" 354887Schin #include "shlex.h" 364887Schin #include "timeout.h" 374887Schin #include "history.h" 384887Schin #include "builtins.h" 394887Schin #include "jobs.h" 404887Schin #include "edit.h" 414887Schin 424887Schin /* error messages */ 434887Schin const char e_timewarn[] = "\r\n\ashell will timeout in 60 seconds due to inactivity"; 444887Schin const char e_runvi[] = "\\hist -e \"${VISUAL:-${EDITOR:-vi}}\" "; 454887Schin const char e_timeout[] = "timed out waiting for input"; 464887Schin const char e_mailmsg[] = "you have mail in $_"; 474887Schin const char e_query[] = "no query process"; 484887Schin const char e_history[] = "no history file"; 494887Schin const char e_histopen[] = "history file cannot open"; 504887Schin const char e_option[] = "%s: bad option(s)"; 514887Schin const char e_toomany[] = "open file limit exceeded"; 524887Schin const char e_argtype[] = "invalid argument of type %c"; 5310898Sroland.mainz@nrubsig.org const char e_oneoperand[] = "one operand expected"; 544887Schin const char e_formspec[] = "%c: unknown format specifier"; 554887Schin const char e_badregexp[] = "%s: invalid regular expression"; 564887Schin const char e_number[] = "%s: bad number"; 574887Schin const char e_badlocale[] = "%s: unknown locale"; 584887Schin const char e_nullset[] = "%s: parameter null"; 594887Schin const char e_notset[] = "%s: parameter not set"; 604887Schin const char e_noparent[] = "%s: no parent"; 614887Schin const char e_subst[] = "%s: bad substitution"; 624887Schin const char e_create[] = "%s: cannot create"; 634887Schin const char e_tmpcreate[] = "cannot create temporary file"; 644887Schin const char e_restricted[] = "%s: restricted"; 654887Schin const char e_pfsh[] = "%s: disabled in profile shell"; 664887Schin const char e_pexists[] = "process already exists"; 674887Schin const char e_exists[] = "%s: file already exists"; 684887Schin const char e_pipe[] = "cannot create pipe"; 694887Schin const char e_alarm[] = "cannot set alarm"; 704887Schin const char e_open[] = "%s: cannot open"; 714887Schin const char e_notseek[] = "%s: not seekable"; 724887Schin const char e_badseek[] = "%s: invalid seek offset"; 734887Schin const char e_badpattern[] = "%s: invalid shell pattern"; 744887Schin const char e_noread[] = "%s: pattern seek requires read access"; 754887Schin const char e_logout[] = "Use 'exit' to terminate this shell"; 764887Schin const char e_exec[] = "%s: cannot execute"; 774887Schin const char e_pwd[] = "cannot access parent directories"; 784887Schin const char e_found[] = "%s: not found"; 794887Schin const char e_defined[] = "%s: function not defined"; 804887Schin const char e_nointerp[] = "%s: interpreter not found"; 814887Schin const char e_subscript[] = "%s: subscript out of range"; 824887Schin const char e_toodeep[] = "%s: recursion too deep"; 834887Schin const char e_access[] = "permission denied"; 844887Schin #ifdef _cmd_universe 854887Schin const char e_nouniverse[] = "universe not accessible"; 864887Schin #endif /* _cmd_universe */ 874887Schin const char e_direct[] = "bad directory"; 884887Schin const char e_file[] = "%s: bad file unit number"; 8910898Sroland.mainz@nrubsig.org const char e_redirect[] = "redirection failed"; 904887Schin const char e_trap[] = "%s: bad trap"; 914887Schin const char e_readonly[] = "%s: is read only"; 924887Schin const char e_badfield[] = "%d: negative field size"; 934887Schin const char e_ident[] = "%s: is not an identifier"; 944887Schin const char e_badname[] = "%s: invalid name"; 954887Schin const char e_varname[] = "%s: invalid variable name"; 964887Schin const char e_badfun[] = "%s: invalid function name"; 974887Schin const char e_aliname[] = "%s: invalid alias name"; 9810898Sroland.mainz@nrubsig.org const char e_badexport[] = "%s: only simple variables can be exported"; 994887Schin const char e_badref[] = "%s: reference variable cannot be an array"; 10010898Sroland.mainz@nrubsig.org const char e_badsubscript[] = "%c: invalid subscript in assignment"; 1014887Schin const char e_noarray[] = "%s: cannot be an array"; 1028462SApril.Chin@Sun.COM const char e_badappend[] = "%s: invalid append to associative array"; 1034887Schin const char e_noref[] = "%s: no reference name"; 1044887Schin const char e_selfref[] = "%s: invalid self reference"; 10510898Sroland.mainz@nrubsig.org const char e_globalref[] = "%s: global reference cannot refer to local variable"; 1064887Schin const char e_noalias[] = "%s: alias not found\n"; 1074887Schin const char e_format[] = "%s: bad format"; 1084887Schin const char e_redef[] = "%s: type cannot be redefined"; 1098462SApril.Chin@Sun.COM const char e_required[] = "%s: is a required element of %s"; 1104887Schin const char e_badtformat[] = "%c: bad format character in time format"; 1114887Schin const char e_nolabels[] = "%s: label not implemented"; 1124887Schin const char e_notimp[] = "%s: not implemented"; 1138462SApril.Chin@Sun.COM const char e_notelem[] = "%.*s: is not an element of %s"; 1148462SApril.Chin@Sun.COM const char e_notenum[] = "%s: not an enumeration type"; 1158462SApril.Chin@Sun.COM const char e_unknowntype[] = "%.*s: unknown type"; 1164887Schin const char e_nosupport[] = "not supported"; 1174887Schin const char e_badrange[] = "%d-%d: invalid range"; 1184887Schin const char e_eneedsarg[] = "-e - requires single argument"; 1194887Schin const char e_badbase[] = "%s unknown base"; 1204887Schin const char e_loop[] = "%s: would cause loop"; 1214887Schin const char e_overlimit[] = "%s: limit exceeded"; 1224887Schin const char e_badsyntax[] = "incorrect syntax"; 1234887Schin const char e_badwrite[] = "write to %d failed"; 1244887Schin const char e_on [] = "on"; 1254887Schin const char e_off[] = "off"; 1264887Schin const char is_reserved[] = " is a keyword"; 1274887Schin const char is_builtin[] = " is a shell builtin"; 1288462SApril.Chin@Sun.COM const char is_spcbuiltin[] = " is a special shell builtin"; 1294887Schin const char is_builtver[] = "is a shell builtin version of"; 1304887Schin const char is_alias[] = "%s is an alias for "; 1314887Schin const char is_xalias[] = "%s is an exported alias for "; 1324887Schin const char is_talias[] = "is a tracked alias for"; 1334887Schin const char is_function[] = " is a function"; 1344887Schin const char is_ufunction[] = " is an undefined function"; 1354887Schin #ifdef JOBS 1364887Schin # ifdef SIGTSTP 1374887Schin const char e_newtty[] = "Switching to new tty driver..."; 1384887Schin const char e_oldtty[] = "Reverting to old tty driver..."; 1394887Schin const char e_no_start[] = "Cannot start job control"; 1404887Schin # endif /*SIGTSTP */ 1414887Schin const char e_no_jctl[] = "No job control"; 1424887Schin const char e_terminate[] = "You have stopped jobs"; 1434887Schin const char e_done[] = " Done"; 1444887Schin const char e_nlspace[] = "\n "; 1454887Schin const char e_running[] = " Running"; 1464887Schin const char e_ambiguous[] = "%s: Ambiguous"; 1474887Schin const char e_jobsrunning[] = "You have running jobs"; 1484887Schin const char e_no_job[] = "no such job"; 1494887Schin const char e_no_proc[] = "no such process"; 1504887Schin const char e_jobusage[] = "%s: Arguments must be %%job or process ids"; 1514887Schin #endif /* JOBS */ 1524887Schin const char e_coredump[] = "(coredump)"; 1534887Schin const char e_alphanum[] = "[_[:alpha:]]*([_[:alnum:]])"; 1544887Schin const char e_devfdNN[] = "/dev/fd/+([0-9])"; 1554887Schin const char e_devfdstd[] = "/dev/@(fd/+([0-9])|std@(in|out|err))"; 1564887Schin const char e_signo[] = "Signal %d"; 1574887Schin #if SHOPT_FS_3D 1584887Schin const char e_cantget[] = "cannot get %s"; 1594887Schin const char e_cantset[] = "cannot set %s"; 1604887Schin const char e_mapping[] = "mapping"; 1614887Schin const char e_versions[] = "versions"; 1624887Schin #endif /* SHOPT_FS_3D */ 1634887Schin 1644887Schin /* string constants */ 1654887Schin const char e_heading[] = "Current option settings"; 1664887Schin const char e_sptbnl[] = " \t\n"; 1674887Schin const char e_defpath[] = "/bin:/usr/bin:"; 1684887Schin const char e_defedit[] = "/bin/ed"; 1694887Schin const char e_unknown [] = "<command unknown>"; 1704887Schin const char e_devnull[] = "/dev/null"; 1714887Schin const char e_traceprompt[] = "+ "; 1724887Schin const char e_supprompt[] = "# "; 1734887Schin const char e_stdprompt[] = "$ "; 1744887Schin const char e_profile[] = "$HOME/.profile"; 1754887Schin const char e_sysprofile[] = "/etc/profile"; 1764887Schin const char e_suidprofile[] = "/etc/suid_profile"; 1774887Schin #if SHOPT_SYSRC 1784887Schin const char e_sysrc[] = "/etc/ksh.kshrc"; 1794887Schin #endif 1804887Schin #if SHOPT_BASH 1814887Schin #if SHOPT_SYSRC 1824887Schin const char e_bash_sysrc[] = "/etc/bash.bashrc"; 1834887Schin #endif 1844887Schin const char e_bash_rc[] = "$HOME/.bashrc"; 1854887Schin const char e_bash_login[] = "$HOME/.bash_login"; 1864887Schin const char e_bash_logout[] = "$HOME/.bash_logout"; 1874887Schin const char e_bash_profile[] = "$HOME/.bash_profile"; 1884887Schin #endif 1894887Schin const char e_crondir[] = "/usr/spool/cron/atjobs"; 1904887Schin const char e_prohibited[] = "login setuid/setgid shells prohibited"; 1914887Schin #if SHOPT_SUID_EXEC 1924887Schin const char e_suidexec[] = "/etc/suid_exec"; 1934887Schin #endif /* SHOPT_SUID_EXEC */ 1944887Schin const char hist_fname[] = "/.sh_history"; 1954887Schin const char e_dot[] = "."; 1964887Schin const char e_envmarker[] = "A__z"; 1974887Schin const char e_timeformat[] = "\nreal\t%2lR\nuser\t%2lU\nsys\t%2lS"; 1984887Schin const char e_dict[] = "libshell"; 199