1 /* @(#)str.c 1.36 18/07/02 Copyright 1986-2018 J. Schilling */ 2 #include <schily/mconfig.h> 3 #ifndef lint 4 static UConst char sccsid[] = 5 "@(#)str.c 1.36 18/07/02 Copyright 1986-2018 J. Schilling"; 6 #endif 7 /* 8 * Copyright (c) 1986-2018 J. Schilling 9 */ 10 /* 11 * The contents of this file are subject to the terms of the 12 * Common Development and Distribution License, Version 1.0 only 13 * (the "License"). You may not use this file except in compliance 14 * with the License. 15 * 16 * See the file CDDL.Schily.txt in this distribution for details. 17 * A copy of the CDDL is also available via the Internet at 18 * http://www.opensource.org/licenses/cddl1.txt 19 * 20 * When distributing Covered Code, include this CDDL HEADER in each 21 * file and include the License file CDDL.Schily.txt from this distribution. 22 */ 23 24 #include <schily/stdio.h> 25 #include <schily/signal.h> 26 #include "bsh.h" 27 28 char relmsg[] = "\ 29 \ 30 bsh V%d.%02d %s (%s-%s-%s)\n\n\ 31 By J. Schilling\n\ 32 bsh -> best shell\n"; 33 34 char bshopts[] = "v,V,i,c,e,h,2,g,l,n,s,t,f,F,o&,q,alias-owner*,noclose,help,version"; 35 36 char sysinitname[] = "/etc/initbsh"; 37 char sysrinitname[] = "/etc/initrbsh"; 38 char initname[] = ".init"; 39 char init2name[] = ".init2"; 40 char finalname[] = ".final"; 41 #ifdef NEW 42 char globalname[] = ".alias"; 43 char localname[] = ".lalias"; 44 #else 45 char globalname[] = ".globals"; 46 char localname[] = ".locals"; 47 #endif 48 char aliasname[] = ".alias"; 49 char laliasname[] = ".lalias"; 50 char historyname[] = ".history"; 51 char mapname[] = ".bshmap"; 52 char defpath[] = ":/usr/ucb:/bin:/usr/bin"; 53 char tmpname[] = "/tmp/bsh"; 54 char nulldev[] = "/dev/null"; 55 char loginname[] = "login"; 56 57 /* 58 * Conditions 59 */ 60 char sn_ctlc[] = "kill"; 61 char sn_no_mem[] = "no_memory"; 62 char sn_any_other[] = "any_other"; 63 char sn_badtab[] = "bad_astab_number"; 64 char sn_badfile[] = "bad_sym_file"; 65 66 /* 67 * Open Modes 68 */ 69 char for_read[] = "r"; 70 char for_ru[] = "ru"; 71 char for_rwct[] = "rwct"; 72 char for_wct[] = "wct"; 73 char for_wca[] = "wca"; 74 75 /* 76 * Environment 77 */ 78 char homename[] = "HOME"; 79 char pathname[] = "PATH"; 80 char termname[] = "TERM"; 81 char termcapname[] = "TERMCAP"; 82 char cwdname[] = "CWD"; 83 char pwdname[] = "PWD"; /* ksh calls it present working dir */ 84 char cdpathname[] = "CDPATH"; 85 char username[] = "USER"; 86 char Elogname[] = "LOGNAME"; 87 char promptname[] = "PROMPT"; 88 char prompt2name[] = "PROMPT2"; 89 char ignoreeofname[] = "IGNOREEOF"; 90 char histname[] = "HISTORY"; /* Historic name */ 91 char savehistname[] = "SAVEHISTORY"; /* Historic name */ 92 char histsizename[] = "HISTSIZE"; /* POSIX name taken from ksh */ 93 char histfilename[] = "HISTFILE"; /* POSIX name taken from ksh */ 94 char slashname[] = "SLASH"; 95 char evlockname[] = "EVLOCK"; 96 char mailname[] = "MAIL"; 97 char mchkname[] = "MAILCHECK"; 98 char mailpname[] = "MAILPATH"; 99 100 char nullstr[] = ""; 101 char nl[] = "\n"; 102 char slash[] = "/"; 103 char eql[] = "="; 104 char lpar[] = "("; 105 char rpar[] = ")"; 106 char on[] = "on"; 107 char off[] = "off"; 108 char commandname[] = "command"; 109 char pipename[] = "pipe"; 110 111 /* 112 * Parser 113 */ 114 char special[] = ";&|()<>% \t"; 115 char ops[] = ";&|)"; 116 char spaces[] = " \t\n"; 117 118 /* 119 * Error Messages 120 */ 121 char ecantcreate[] = "Can't create '%s'. %s"; 122 char ecantopen[] = "Can't open '%s'. %s"; 123 char ecantread[] = "Can't read '%s'. %s"; 124 char ecantexecute[] = "Can't execute '%s'. %s"; 125 char ecantfork[] = "Can't fork %s"; 126 char ecantvfork[] = "Can't vfork %s"; 127 char enochildren[] = "No children."; 128 char eargtoolong[] = "Argument too long."; 129 char erestricted[] = "%s: restricted."; 130 char ebadopt[] = "%s: Bad Option: %s."; 131 char eioredef[] = "I/O redefined."; 132 char eiounimpl[] = "Unimplemented I/O."; 133 char epiperedefio[] = "Pipe redefines I/O."; 134 char emissing[] = "Missing"; 135 char emissiodelim[] = "Missing I/O delimiter."; 136 char emissnameinio[] = "Missing I/O name."; 137 char emissterm[] = "Missing I/O terminator."; 138 char emisscondcmd[] = "Missing command in conditional."; 139 char emisspipecmd[] = "Missing command in pipe."; 140 char emissabbrev[] = "Missing abbrev name."; 141 char enocmd[] = "Unknown command."; 142 char enullcmd[] = "Null command name."; 143 char eambiguous[] = "Ambiguous."; 144 char ebadmodifier[] = "Bad modifier."; 145 char ebadpattern[] = "Bad pattern."; 146 char enotfound[] = "Not found."; 147 char eshonly[] = "#! only works in commandfiles."; 148 char ecore[] = " - core dumped"; 149 #ifdef TEST /* include test code */ 150 char ebadop[] = "bad operator: %s"; 151 char expected[] = "%s expected"; 152 char unexpected[] = "%s unexpected"; 153 char number[] = "number"; 154 char argument[] = "argument"; 155 char divzero[] = "division by zero"; 156 #endif 157 158 159 /* 160 * Usage Messages 161 */ 162 char helpname[] = "-help"; 163 char usage[] = "Usage: "; 164 char ubsh[] = "\ 165 [options] [arg1 ... argn]\n\ 166 Read commands from file arg1. If no args,\n\ 167 Read commands from stdin.\n\ 168 Options:\n\ 169 -i Force interactive prompting.\n\ 170 -v Set verbose mode after processing dotfiles.\n\ 171 -V Start with verbose mode on.\n\ 172 -c Execute arg1 as a command with arg2-n as args.\n\ 173 -e Exit immediately if a noninteractive command fails.\n\ 174 -n Read commands but do not execute them.\n\ 175 -s Read commands from stdin - even if args.\n\ 176 -t Exit after reading and executing one command.\n\ 177 -2 Don't read ~/.init2 file.\n\ 178 also true if -c set and name is 'command'.\n\ 179 -h Don't use ~/.history file.\n\ 180 -g Don't use ~/.globals file.\n\ 181 -l Don't use .locals file.\n\ 182 -f (fast) same as -2h.\n\ 183 -F (extra fast) same as -2hgl.\n\ 184 -noclose Don't close nostd files on exec."; 185 186 char ualias[] = "[name[=value]...]\n\ 187 Options:\n\ 188 -a Define a non-begin alias.\n\ 189 -e List the everlasting version of the persistent alias.\n\ 190 -g Define or list persistent global aliases.\n\ 191 -l Define or list persistent local aliases.\n\ 192 -p Push alias or list in parsable form.\n\ 193 -reload Reload aliases from file.\n\ 194 -R/-raw Output listing in raw format."; 195 char uunalias[] = "[name...]\n\ 196 Options:\n\ 197 -a Remove all alias definitions.\n\ 198 -g Pop a single global alias definition.\n\ 199 -l Pop a single local alias definition.\n\ 200 -p Pop all on named alias definition."; 201 char uexpr[] = "name = expr"; 202 char ufg[] = "[job ...]"; 203 char ubrack[] = "expr ]"; 204 char ucd[] = "[directory]"; 205 char uconcat[] = "name val1 ... valn"; 206 char udo[] = "command"; 207 char uecho[] = "[-n|-nnl] args"; 208 char uenv[] = "[-i] [name=value] [command [args]]"; 209 char uerrstr[] = "errno"; 210 char ueval[] = "[args]"; 211 char uexec[] = "[av0=name] [args]"; 212 char uexit[] = "[exitcode]"; 213 char ufunc[] = "[funcname] ['cmdlist']"; 214 char uglob[] = "args"; 215 char uhist[] = "[-n][-r]"; 216 char ukill[] = "[-l][-sig] pid1 ... pidn"; 217 char uulimit[] = "[[resource] [[curlimit] [maxlimit]]]"; 218 char ulogin[] = "[username]"; 219 char umap[] = "[fromstr [tostr [comment]]]\n\ 220 Options:\n\ 221 -r reload mappings\n\ 222 -u unmap fromstr"; 223 char upgrp[] = "[pid]"; 224 char upopd[] = "[offset]"; 225 char upushd[] = "[directory|offset]"; 226 char uread[] = "varname"; 227 char urepeat[] = "\ 228 [delay=seconds] [count=times] command\n\ 229 All flags must be before the command to be repeated."; 230 char uresume[] = "pid"; 231 char uset[] = "[name=value]"; 232 char usetenv[] = "[name value]"; 233 char usetmask[] = "\ 234 [+-]{rwx} [+-]{rwx} [+-]{rwx}\n\ 235 \t Owner Group World\n\n\ 236 Accepted mode characters are also :\n\ 237 = same mode as before\n\ 238 . delete all permissions"; 239 char ushift[] = "[count]"; 240 char usignal[] = "['cmdlist'] [sig#1 .. sig#n]"; 241 char usource[] = "[-h] bshfile"; 242 char udot[] = "shellfile"; 243 char ureturn[] = "[retval]"; 244 char ustop[] = "pid1 ... pidn"; 245 #ifdef DO_SUID 246 char usuid[] = "\ 247 [name]\n\ 248 The user will be prompted for password"; 249 #endif 250 char ususpend[] = "[pid1 ... pidn]"; 251 char utest[] = "expr"; 252 char utype[] = "name ..."; 253 char uutime[] = "noch nicht fertig"; 254 char uumask[] = "[-S] [mask]"; 255 char uunmap[] = "fromstr"; 256 char uunset[] = "name"; 257 char uunsetenv[] = "name"; 258 char uwait[] = "pid1 ... pidn"; 259