Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 874 lines (801 sloc) 26.933 kb
e74702b Initial revision
Tanaka Akira authored
1 /*
2 * options.c - shell options
3 *
4 * This file is part of zsh, the Z shell.
5 *
6 * Copyright (c) 1992-1997 Paul Falstad
7 * All rights reserved.
8 *
9 * Permission is hereby granted, without written agreement and without
10 * license or royalty fees, to use, copy, modify, and distribute this
11 * software and to distribute modified versions of this software for any
12 * purpose, provided that the above copyright notice and the following
13 * two paragraphs appear in all copies of this software.
14 *
15 * In no event shall Paul Falstad or the Zsh Development Group be liable
16 * to any party for direct, indirect, special, incidental, or consequential
17 * damages arising out of the use of this software and its documentation,
18 * even if Paul Falstad and the Zsh Development Group have been advised of
19 * the possibility of such damage.
20 *
21 * Paul Falstad and the Zsh Development Group specifically disclaim any
22 * warranties, including, but not limited to, the implied warranties of
23 * merchantability and fitness for a particular purpose. The software
24 * provided hereunder is on an "as is" basis, and Paul Falstad and the
25 * Zsh Development Group have no obligation to provide maintenance,
26 * support, updates, enhancements, or modifications.
27 *
28 */
29
30 #include "zsh.mdh"
31 #include "options.pro"
32
33 /* current emulation (used to decide which set of option letters is used) */
34
35 /**/
405fd07 22057: don't use zsh/newuser in emulation
Peter Stephenson authored
36 mod_export int emulation;
e74702b Initial revision
Tanaka Akira authored
37
c7d8b0d 26546, 26556: sticky emulation for functions defined in emulate ... -…
Peter Stephenson authored
38 /* current sticky emulation: 0 means none */
39
40 /**/
41 mod_export int sticky_emulation;
42
e74702b Initial revision
Tanaka Akira authored
43 /* the options; e.g. if opts[SHGLOB] != 0, SH_GLOB is turned on */
44
45 /**/
5c53fb9 10771: new GLOBAL_EXPORT option; successful compilation on OpenBSD
Peter Stephenson authored
46 mod_export char opts[OPT_SIZE];
e74702b Initial revision
Tanaka Akira authored
47
48 /* Option name hash table */
49
50 /**/
5c53fb9 10771: new GLOBAL_EXPORT option; successful compilation on OpenBSD
Peter Stephenson authored
51 mod_export HashTable optiontab;
e74702b Initial revision
Tanaka Akira authored
52
53 /* The canonical option name table */
54
55 #define OPT_CSH EMULATE_CSH
56 #define OPT_KSH EMULATE_KSH
57 #define OPT_SH EMULATE_SH
58 #define OPT_ZSH EMULATE_ZSH
59
60 #define OPT_ALL (OPT_CSH|OPT_KSH|OPT_SH|OPT_ZSH)
61 #define OPT_BOURNE (OPT_KSH|OPT_SH)
62 #define OPT_BSHELL (OPT_KSH|OPT_SH|OPT_ZSH)
63 #define OPT_NONBOURNE (OPT_ALL & ~OPT_BOURNE)
64 #define OPT_NONZSH (OPT_ALL & ~OPT_ZSH)
65
c7d8b0d 26546, 26556: sticky emulation for functions defined in emulate ... -…
Peter Stephenson authored
66 /* option is relevant to emulation */
67 #define OPT_EMULATE (EMULATE_UNUSED)
68 /* option should never be set by emulate() */
69 #define OPT_SPECIAL (EMULATE_UNUSED<<1)
70 /* option is an alias to an other option */
71 #define OPT_ALIAS (EMULATE_UNUSED<<2)
e74702b Initial revision
Tanaka Akira authored
72
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
73 #define defset(X) (!!((X)->node.flags & emulation))
e74702b Initial revision
Tanaka Akira authored
74
5c53fb9 10771: new GLOBAL_EXPORT option; successful compilation on OpenBSD
Peter Stephenson authored
75 /*
76 * Note that option names should usually be fewer than 20 characters long
77 * to avoid formatting problems.
78 */
e74702b Initial revision
Tanaka Akira authored
79 static struct optname optns[] = {
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
80 {{NULL, "aliases", OPT_EMULATE|OPT_ALL}, ALIASESOPT},
81 {{NULL, "allexport", OPT_EMULATE}, ALLEXPORT},
82 {{NULL, "alwayslastprompt", OPT_ALL}, ALWAYSLASTPROMPT},
83 {{NULL, "alwaystoend", 0}, ALWAYSTOEND},
84 {{NULL, "appendhistory", OPT_ALL}, APPENDHISTORY},
85 {{NULL, "autocd", OPT_EMULATE}, AUTOCD},
86 {{NULL, "autocontinue", 0}, AUTOCONTINUE},
87 {{NULL, "autolist", OPT_ALL}, AUTOLIST},
88 {{NULL, "automenu", OPT_ALL}, AUTOMENU},
89 {{NULL, "autonamedirs", 0}, AUTONAMEDIRS},
90 {{NULL, "autoparamkeys", OPT_ALL}, AUTOPARAMKEYS},
91 {{NULL, "autoparamslash", OPT_ALL}, AUTOPARAMSLASH},
92 {{NULL, "autopushd", 0}, AUTOPUSHD},
93 {{NULL, "autoremoveslash", OPT_ALL}, AUTOREMOVESLASH},
94 {{NULL, "autoresume", 0}, AUTORESUME},
95 {{NULL, "badpattern", OPT_EMULATE|OPT_NONBOURNE},BADPATTERN},
96 {{NULL, "banghist", OPT_NONBOURNE}, BANGHIST},
97 {{NULL, "bareglobqual", OPT_EMULATE|OPT_ZSH}, BAREGLOBQUAL},
98 {{NULL, "bashautolist", 0}, BASHAUTOLIST},
7f03c3d 23375: Phil Pennock: =~, zsh/regex etc. etc.
Peter Stephenson authored
99 {{NULL, "bashrematch", 0}, BASHREMATCH},
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
100 {{NULL, "beep", OPT_ALL}, BEEP},
101 {{NULL, "bgnice", OPT_EMULATE|OPT_NONBOURNE},BGNICE},
102 {{NULL, "braceccl", OPT_EMULATE}, BRACECCL},
103 {{NULL, "bsdecho", OPT_EMULATE|OPT_SH}, BSDECHO},
104 {{NULL, "caseglob", OPT_ALL}, CASEGLOB},
7f03c3d 23375: Phil Pennock: =~, zsh/regex etc. etc.
Peter Stephenson authored
105 {{NULL, "casematch", OPT_ALL}, CASEMATCH},
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
106 {{NULL, "cbases", 0}, CBASES},
8a4af21 25149: add C_PRECEDENCES option to make arithmetic have C/Perl preced…
Peter Stephenson authored
107 {{NULL, "cprecedences", OPT_EMULATE|OPT_NONZSH}, CPRECEDENCES},
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
108 {{NULL, "cdablevars", OPT_EMULATE}, CDABLEVARS},
109 {{NULL, "chasedots", OPT_EMULATE}, CHASEDOTS},
110 {{NULL, "chaselinks", OPT_EMULATE}, CHASELINKS},
111 {{NULL, "checkjobs", OPT_EMULATE|OPT_ZSH}, CHECKJOBS},
112 {{NULL, "clobber", OPT_EMULATE|OPT_ALL}, CLOBBER},
97dcf15 24808: initial support for combining characters in zle
Peter Stephenson authored
113 {{NULL, "combiningchars", 0}, COMBININGCHARS},
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
114 {{NULL, "completealiases", 0}, COMPLETEALIASES},
115 {{NULL, "completeinword", 0}, COMPLETEINWORD},
116 {{NULL, "correct", 0}, CORRECT},
117 {{NULL, "correctall", 0}, CORRECTALL},
118 {{NULL, "cshjunkiehistory", OPT_EMULATE|OPT_CSH}, CSHJUNKIEHISTORY},
119 {{NULL, "cshjunkieloops", OPT_EMULATE|OPT_CSH}, CSHJUNKIELOOPS},
120 {{NULL, "cshjunkiequotes", OPT_EMULATE|OPT_CSH}, CSHJUNKIEQUOTES},
121 {{NULL, "cshnullcmd", OPT_EMULATE|OPT_CSH}, CSHNULLCMD},
122 {{NULL, "cshnullglob", OPT_EMULATE|OPT_CSH}, CSHNULLGLOB},
2706eac 25415: Make DEBUG_BEFORE_CMD the default.
Peter Stephenson authored
123 {{NULL, "debugbeforecmd", OPT_ALL}, DEBUGBEFORECMD},
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
124 {{NULL, "emacs", 0}, EMACSMODE},
125 {{NULL, "equals", OPT_EMULATE|OPT_ZSH}, EQUALS},
126 {{NULL, "errexit", OPT_EMULATE}, ERREXIT},
127 {{NULL, "errreturn", OPT_EMULATE}, ERRRETURN},
128 {{NULL, "exec", OPT_ALL}, EXECOPT},
129 {{NULL, "extendedglob", OPT_EMULATE}, EXTENDEDGLOB},
130 {{NULL, "extendedhistory", OPT_CSH}, EXTENDEDHISTORY},
131 {{NULL, "evallineno", OPT_EMULATE|OPT_ZSH}, EVALLINENO},
132 {{NULL, "flowcontrol", OPT_ALL}, FLOWCONTROL},
133 {{NULL, "functionargzero", OPT_EMULATE|OPT_NONBOURNE},FUNCTIONARGZERO},
134 {{NULL, "glob", OPT_EMULATE|OPT_ALL}, GLOBOPT},
135 {{NULL, "globalexport", OPT_EMULATE|OPT_ZSH}, GLOBALEXPORT},
136 {{NULL, "globalrcs", OPT_ALL}, GLOBALRCS},
137 {{NULL, "globassign", OPT_EMULATE|OPT_CSH}, GLOBASSIGN},
138 {{NULL, "globcomplete", 0}, GLOBCOMPLETE},
139 {{NULL, "globdots", OPT_EMULATE}, GLOBDOTS},
140 {{NULL, "globsubst", OPT_EMULATE|OPT_NONZSH}, GLOBSUBST},
141 {{NULL, "hashcmds", OPT_ALL}, HASHCMDS},
142 {{NULL, "hashdirs", OPT_ALL}, HASHDIRS},
c214b86 30101: add HASH_EXECUTABLES_ONLY option
Peter Stephenson authored
143 {{NULL, "hashexecutablesonly", 0}, HASHEXECUTABLESONLY},
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
144 {{NULL, "hashlistall", OPT_ALL}, HASHLISTALL},
145 {{NULL, "histallowclobber", 0}, HISTALLOWCLOBBER},
146 {{NULL, "histbeep", OPT_ALL}, HISTBEEP},
147 {{NULL, "histexpiredupsfirst",0}, HISTEXPIREDUPSFIRST},
78ce07b 24818: add HIST_FCNTL_LOCK.
Peter Stephenson authored
148 {{NULL, "histfcntllock", 0}, HISTFCNTLLOCK},
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
149 {{NULL, "histfindnodups", 0}, HISTFINDNODUPS},
150 {{NULL, "histignorealldups", 0}, HISTIGNOREALLDUPS},
151 {{NULL, "histignoredups", 0}, HISTIGNOREDUPS},
152 {{NULL, "histignorespace", 0}, HISTIGNORESPACE},
66f32a8 28308/28310: HIST_LEX_WORDS, check for quick history read
Peter Stephenson authored
153 {{NULL, "histlexwords", 0}, HISTLEXWORDS},
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
154 {{NULL, "histnofunctions", 0}, HISTNOFUNCTIONS},
155 {{NULL, "histnostore", 0}, HISTNOSTORE},
9471bbc 22934, modified, see 22937: add HIST_SUBST_PATTERN option
Peter Stephenson authored
156 {{NULL, "histsubstpattern", OPT_EMULATE}, HISTSUBSTPATTERN},
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
157 {{NULL, "histreduceblanks", 0}, HISTREDUCEBLANKS},
158 {{NULL, "histsavebycopy", OPT_ALL}, HISTSAVEBYCOPY},
159 {{NULL, "histsavenodups", 0}, HISTSAVENODUPS},
160 {{NULL, "histverify", 0}, HISTVERIFY},
161 {{NULL, "hup", OPT_EMULATE|OPT_ZSH}, HUP},
162 {{NULL, "ignorebraces", OPT_EMULATE|OPT_SH}, IGNOREBRACES},
e3182c1 29955++: IGNORE_CLOSE_BRACES option
Peter Stephenson authored
163 {{NULL, "ignoreclosebraces", 0}, IGNORECLOSEBRACES},
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
164 {{NULL, "ignoreeof", 0}, IGNOREEOF},
165 {{NULL, "incappendhistory", 0}, INCAPPENDHISTORY},
166 {{NULL, "interactive", OPT_SPECIAL}, INTERACTIVE},
167 {{NULL, "interactivecomments",OPT_BOURNE}, INTERACTIVECOMMENTS},
168 {{NULL, "ksharrays", OPT_EMULATE|OPT_BOURNE}, KSHARRAYS},
169 {{NULL, "kshautoload", OPT_EMULATE|OPT_BOURNE}, KSHAUTOLOAD},
abae4fe 23562: add KSH_ZERO_SUBSCRIPT option and leave off by default
Peter Stephenson authored
170 {{NULL, "kshglob", OPT_EMULATE|OPT_KSH}, KSHGLOB},
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
171 {{NULL, "kshoptionprint", OPT_EMULATE|OPT_KSH}, KSHOPTIONPRINT},
abae4fe 23562: add KSH_ZERO_SUBSCRIPT option and leave off by default
Peter Stephenson authored
172 {{NULL, "kshtypeset", OPT_EMULATE|OPT_KSH}, KSHTYPESET},
173 {{NULL, "kshzerosubscript", 0}, KSHZEROSUBSCRIPT},
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
174 {{NULL, "listambiguous", OPT_ALL}, LISTAMBIGUOUS},
175 {{NULL, "listbeep", OPT_ALL}, LISTBEEP},
176 {{NULL, "listpacked", 0}, LISTPACKED},
177 {{NULL, "listrowsfirst", 0}, LISTROWSFIRST},
178 {{NULL, "listtypes", OPT_ALL}, LISTTYPES},
179 {{NULL, "localoptions", OPT_EMULATE|OPT_KSH}, LOCALOPTIONS},
180 {{NULL, "localtraps", OPT_EMULATE|OPT_KSH}, LOCALTRAPS},
181 {{NULL, "login", OPT_SPECIAL}, LOGINSHELL},
182 {{NULL, "longlistjobs", 0}, LONGLISTJOBS},
183 {{NULL, "magicequalsubst", OPT_EMULATE}, MAGICEQUALSUBST},
184 {{NULL, "mailwarning", 0}, MAILWARNING},
185 {{NULL, "markdirs", 0}, MARKDIRS},
186 {{NULL, "menucomplete", 0}, MENUCOMPLETE},
187 {{NULL, "monitor", OPT_SPECIAL}, MONITOR},
09bc7ee 22557: turn on multibyte option by default
Peter Stephenson authored
188 {{NULL, "multibyte",
189 #ifdef MULTIBYTE_SUPPORT
d70cfd3 24696: turn off MULTIBYTE by default in sh emulation
Peter Stephenson authored
190 OPT_EMULATE|OPT_ZSH|OPT_CSH|OPT_KSH
09bc7ee 22557: turn on multibyte option by default
Peter Stephenson authored
191 #else
192 0
193 #endif
194 }, MULTIBYTE},
8bb15c1 25641: add emulation option (NO_)MULTI_FUNC_DEF
Peter Stephenson authored
195 {{NULL, "multifuncdef", OPT_EMULATE|OPT_ZSH}, MULTIFUNCDEF},
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
196 {{NULL, "multios", OPT_EMULATE|OPT_ZSH}, MULTIOS},
197 {{NULL, "nomatch", OPT_EMULATE|OPT_NONBOURNE},NOMATCH},
198 {{NULL, "notify", OPT_ZSH}, NOTIFY},
199 {{NULL, "nullglob", OPT_EMULATE}, NULLGLOB},
200 {{NULL, "numericglobsort", OPT_EMULATE}, NUMERICGLOBSORT},
201 {{NULL, "octalzeroes", OPT_EMULATE|OPT_SH}, OCTALZEROES},
202 {{NULL, "overstrike", 0}, OVERSTRIKE},
203 {{NULL, "pathdirs", OPT_EMULATE}, PATHDIRS},
53745d8 27793 and follow ups: add PATH_SCRIPT option to find script using $PATH
Peter Stephenson authored
204 {{NULL, "pathscript", OPT_EMULATE|OPT_BOURNE}, PATHSCRIPT},
8e25f44 26675: add POSIX_ALIASES option
Peter Stephenson authored
205 {{NULL, "posixaliases", OPT_EMULATE|OPT_BOURNE}, POSIXALIASES},
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
206 {{NULL, "posixbuiltins", OPT_EMULATE|OPT_BOURNE}, POSIXBUILTINS},
606cfb5 27167: add POSIX_CD option to test "." after CDPATH
Peter Stephenson authored
207 {{NULL, "posixcd", OPT_EMULATE|OPT_BOURNE}, POSIXCD},
4a67f24 22544: Improve use of ztype tests for multibyte characters. Add
Peter Stephenson authored
208 {{NULL, "posixidentifiers", OPT_EMULATE|OPT_BOURNE}, POSIXIDENTIFIERS},
73be7ee 27106: reset status on command that expands to empty
Peter Stephenson authored
209 {{NULL, "posixjobs", OPT_EMULATE|OPT_BOURNE}, POSIXJOBS},
cc9bc2d 28424: new POSIX_STRINGS option
Peter Stephenson authored
210 {{NULL, "posixstrings", OPT_EMULATE|OPT_BOURNE}, POSIXSTRINGS},
211 {{NULL, "posixtraps", OPT_EMULATE|OPT_BOURNE}, POSIXTRAPS},
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
212 {{NULL, "printeightbit", 0}, PRINTEIGHTBIT},
213 {{NULL, "printexitvalue", 0}, PRINTEXITVALUE},
214 {{NULL, "privileged", OPT_SPECIAL}, PRIVILEGED},
215 {{NULL, "promptbang", OPT_KSH}, PROMPTBANG},
216 {{NULL, "promptcr", OPT_ALL}, PROMPTCR},
217 {{NULL, "promptpercent", OPT_NONBOURNE}, PROMPTPERCENT},
218 {{NULL, "promptsp", OPT_ALL}, PROMPTSP},
c79ccea 25418: set PROMPT_SUBST for all Bourne-style shells
Peter Stephenson authored
219 {{NULL, "promptsubst", OPT_BOURNE}, PROMPTSUBST},
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
220 {{NULL, "pushdignoredups", OPT_EMULATE}, PUSHDIGNOREDUPS},
221 {{NULL, "pushdminus", OPT_EMULATE}, PUSHDMINUS},
222 {{NULL, "pushdsilent", 0}, PUSHDSILENT},
223 {{NULL, "pushdtohome", OPT_EMULATE}, PUSHDTOHOME},
224 {{NULL, "rcexpandparam", OPT_EMULATE}, RCEXPANDPARAM},
225 {{NULL, "rcquotes", OPT_EMULATE}, RCQUOTES},
226 {{NULL, "rcs", OPT_ALL}, RCS},
227 {{NULL, "recexact", 0}, RECEXACT},
7f03c3d 23375: Phil Pennock: =~, zsh/regex etc. etc.
Peter Stephenson authored
228 {{NULL, "rematchpcre", 0}, REMATCHPCRE},
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
229 {{NULL, "restricted", OPT_SPECIAL}, RESTRICTED},
230 {{NULL, "rmstarsilent", OPT_BOURNE}, RMSTARSILENT},
231 {{NULL, "rmstarwait", 0}, RMSTARWAIT},
232 {{NULL, "sharehistory", OPT_KSH}, SHAREHISTORY},
233 {{NULL, "shfileexpansion", OPT_EMULATE|OPT_BOURNE}, SHFILEEXPANSION},
234 {{NULL, "shglob", OPT_EMULATE|OPT_BOURNE}, SHGLOB},
235 {{NULL, "shinstdin", OPT_SPECIAL}, SHINSTDIN},
236 {{NULL, "shnullcmd", OPT_EMULATE|OPT_BOURNE}, SHNULLCMD},
237 {{NULL, "shoptionletters", OPT_EMULATE|OPT_BOURNE}, SHOPTIONLETTERS},
238 {{NULL, "shortloops", OPT_EMULATE|OPT_NONBOURNE},SHORTLOOPS},
239 {{NULL, "shwordsplit", OPT_EMULATE|OPT_BOURNE}, SHWORDSPLIT},
240 {{NULL, "singlecommand", OPT_SPECIAL}, SINGLECOMMAND},
241 {{NULL, "singlelinezle", OPT_KSH}, SINGLELINEZLE},
06b7029 27638, based on Frank Terbeck, 27633: SOURCETRACE option
Peter Stephenson authored
242 {{NULL, "sourcetrace", 0}, SOURCETRACE},
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
243 {{NULL, "sunkeyboardhack", 0}, SUNKEYBOARDHACK},
244 {{NULL, "transientrprompt", 0}, TRANSIENTRPROMPT},
245 {{NULL, "trapsasync", 0}, TRAPSASYNC},
246 {{NULL, "typesetsilent", OPT_EMULATE|OPT_BOURNE}, TYPESETSILENT},
247 {{NULL, "unset", OPT_EMULATE|OPT_BSHELL}, UNSET},
248 {{NULL, "verbose", 0}, VERBOSE},
249 {{NULL, "vi", 0}, VIMODE},
250 {{NULL, "warncreateglobal", 0}, WARNCREATEGLOBAL},
251 {{NULL, "xtrace", 0}, XTRACE},
252 {{NULL, "zle", OPT_SPECIAL}, USEZLE},
253 {{NULL, "braceexpand", OPT_ALIAS}, /* ksh/bash */ -IGNOREBRACES},
254 {{NULL, "dotglob", OPT_ALIAS}, /* bash */ GLOBDOTS},
255 {{NULL, "hashall", OPT_ALIAS}, /* bash */ HASHCMDS},
256 {{NULL, "histappend", OPT_ALIAS}, /* bash */ APPENDHISTORY},
257 {{NULL, "histexpand", OPT_ALIAS}, /* bash */ BANGHIST},
258 {{NULL, "log", OPT_ALIAS}, /* ksh */ -HISTNOFUNCTIONS},
259 {{NULL, "mailwarn", OPT_ALIAS}, /* bash */ MAILWARNING},
260 {{NULL, "onecmd", OPT_ALIAS}, /* bash */ SINGLECOMMAND},
261 {{NULL, "physical", OPT_ALIAS}, /* ksh/bash */ CHASELINKS},
262 {{NULL, "promptvars", OPT_ALIAS}, /* bash */ PROMPTSUBST},
263 {{NULL, "stdin", OPT_ALIAS}, /* ksh */ SHINSTDIN},
264 {{NULL, "trackall", OPT_ALIAS}, /* ksh */ HASHCMDS},
265 {{NULL, "dvorak", 0}, DVORAK},
266 {{NULL, NULL, 0}, 0}
e74702b Initial revision
Tanaka Akira authored
267 };
268
269 /* Option letters */
270
271 #define optletters (isset(SHOPTIONLETTERS) ? kshletters : zshletters)
272
273 #define FIRST_OPT '0'
274 #define LAST_OPT 'y'
275
276 static short zshletters[LAST_OPT - FIRST_OPT + 1] = {
277 /* 0 */ CORRECT,
278 /* 1 */ PRINTEXITVALUE,
279 /* 2 */ -BADPATTERN,
280 /* 3 */ -NOMATCH,
281 /* 4 */ GLOBDOTS,
282 /* 5 */ NOTIFY,
283 /* 6 */ BGNICE,
284 /* 7 */ IGNOREEOF,
285 /* 8 */ MARKDIRS,
286 /* 9 */ AUTOLIST,
287 /* : */ 0,
288 /* ; */ 0,
289 /* < */ 0,
290 /* = */ 0,
291 /* > */ 0,
292 /* ? */ 0,
293 /* @ */ 0,
5c53fb9 10771: new GLOBAL_EXPORT option; successful compilation on OpenBSD
Peter Stephenson authored
294 /* A */ 0, /* use with set for arrays */
e74702b Initial revision
Tanaka Akira authored
295 /* B */ -BEEP,
296 /* C */ -CLOBBER,
297 /* D */ PUSHDTOHOME,
298 /* E */ PUSHDSILENT,
299 /* F */ -GLOBOPT,
300 /* G */ NULLGLOB,
301 /* H */ RMSTARSILENT,
302 /* I */ IGNOREBRACES,
303 /* J */ AUTOCD,
304 /* K */ -BANGHIST,
305 /* L */ SUNKEYBOARDHACK,
306 /* M */ SINGLELINEZLE,
307 /* N */ AUTOPUSHD,
308 /* O */ CORRECTALL,
309 /* P */ RCEXPANDPARAM,
310 /* Q */ PATHDIRS,
311 /* R */ LONGLISTJOBS,
312 /* S */ RECEXACT,
313 /* T */ CDABLEVARS,
314 /* U */ MAILWARNING,
315 /* V */ -PROMPTCR,
316 /* W */ AUTORESUME,
317 /* X */ LISTTYPES,
318 /* Y */ MENUCOMPLETE,
319 /* Z */ USEZLE,
320 /* [ */ 0,
321 /* \ */ 0,
322 /* ] */ 0,
323 /* ^ */ 0,
324 /* _ */ 0,
325 /* ` */ 0,
326 /* a */ ALLEXPORT,
5c53fb9 10771: new GLOBAL_EXPORT option; successful compilation on OpenBSD
Peter Stephenson authored
327 /* b */ 0, /* in non-Bourne shells, end of options */
328 /* c */ 0, /* command follows */
329 /* d */ -GLOBALRCS,
e74702b Initial revision
Tanaka Akira authored
330 /* e */ ERREXIT,
331 /* f */ -RCS,
332 /* g */ HISTIGNORESPACE,
333 /* h */ HISTIGNOREDUPS,
334 /* i */ INTERACTIVE,
335 /* j */ 0,
336 /* k */ INTERACTIVECOMMENTS,
337 /* l */ LOGINSHELL,
338 /* m */ MONITOR,
339 /* n */ -EXECOPT,
5c53fb9 10771: new GLOBAL_EXPORT option; successful compilation on OpenBSD
Peter Stephenson authored
340 /* o */ 0, /* long option name follows */
e74702b Initial revision
Tanaka Akira authored
341 /* p */ PRIVILEGED,
342 /* q */ 0,
343 /* r */ RESTRICTED,
344 /* s */ SHINSTDIN,
345 /* t */ SINGLECOMMAND,
346 /* u */ -UNSET,
347 /* v */ VERBOSE,
348 /* w */ CHASELINKS,
349 /* x */ XTRACE,
350 /* y */ SHWORDSPLIT,
351 };
352
353 static short kshletters[LAST_OPT - FIRST_OPT + 1] = {
354 /* 0 */ 0,
355 /* 1 */ 0,
356 /* 2 */ 0,
357 /* 3 */ 0,
358 /* 4 */ 0,
359 /* 5 */ 0,
360 /* 6 */ 0,
361 /* 7 */ 0,
362 /* 8 */ 0,
363 /* 9 */ 0,
364 /* : */ 0,
365 /* ; */ 0,
366 /* < */ 0,
367 /* = */ 0,
368 /* > */ 0,
369 /* ? */ 0,
370 /* @ */ 0,
371 /* A */ 0,
372 /* B */ 0,
373 /* C */ -CLOBBER,
374 /* D */ 0,
375 /* E */ 0,
376 /* F */ 0,
377 /* G */ 0,
378 /* H */ 0,
379 /* I */ 0,
380 /* J */ 0,
381 /* K */ 0,
382 /* L */ 0,
383 /* M */ 0,
384 /* N */ 0,
385 /* O */ 0,
386 /* P */ 0,
387 /* Q */ 0,
388 /* R */ 0,
389 /* S */ 0,
b5ceb73 zsh-users/7365: new TRAPS_ASYNC option
Peter Stephenson authored
390 /* T */ TRAPSASYNC,
e74702b Initial revision
Tanaka Akira authored
391 /* U */ 0,
392 /* V */ 0,
393 /* W */ 0,
394 /* X */ MARKDIRS,
395 /* Y */ 0,
396 /* Z */ 0,
397 /* [ */ 0,
398 /* \ */ 0,
399 /* ] */ 0,
400 /* ^ */ 0,
401 /* _ */ 0,
402 /* ` */ 0,
403 /* a */ ALLEXPORT,
404 /* b */ NOTIFY,
405 /* c */ 0,
406 /* d */ 0,
407 /* e */ ERREXIT,
408 /* f */ -GLOBOPT,
409 /* g */ 0,
410 /* h */ 0,
411 /* i */ INTERACTIVE,
412 /* j */ 0,
413 /* k */ 0,
414 /* l */ LOGINSHELL,
415 /* m */ MONITOR,
416 /* n */ -EXECOPT,
417 /* o */ 0,
418 /* p */ PRIVILEGED,
419 /* q */ 0,
420 /* r */ RESTRICTED,
421 /* s */ SHINSTDIN,
422 /* t */ SINGLECOMMAND,
423 /* u */ -UNSET,
424 /* v */ VERBOSE,
425 /* w */ 0,
426 /* x */ XTRACE,
427 /* y */ 0,
428 };
429
430 /* Initialisation of the option name hash table */
431
432 /**/
433 static void
434 printoptionnode(HashNode hn, int set)
435 {
436 Optname on = (Optname) hn;
437 int optno = on->optno;
438
439 if (optno < 0)
440 optno = -optno;
441 if (isset(KSHOPTIONPRINT)) {
442 if (defset(on))
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
443 printf("no%-19s %s\n", on->node.nam, isset(optno) ? "off" : "on");
e74702b Initial revision
Tanaka Akira authored
444 else
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
445 printf("%-21s %s\n", on->node.nam, isset(optno) ? "on" : "off");
e74702b Initial revision
Tanaka Akira authored
446 } else if (set == (isset(optno) ^ defset(on))) {
447 if (set ^ isset(optno))
448 fputs("no", stdout);
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
449 puts(on->node.nam);
e74702b Initial revision
Tanaka Akira authored
450 }
451 }
452
453 /**/
454 void
455 createoptiontable(void)
456 {
457 Optname on;
458
459 optiontab = newhashtable(101, "optiontab", NULL);
460
461 optiontab->hash = hasher;
462 optiontab->emptytable = NULL;
463 optiontab->filltable = NULL;
5c53fb9 10771: new GLOBAL_EXPORT option; successful compilation on OpenBSD
Peter Stephenson authored
464 optiontab->cmpnodes = strcmp;
e74702b Initial revision
Tanaka Akira authored
465 optiontab->addnode = addhashnode;
466 optiontab->getnode = gethashnode;
467 optiontab->getnode2 = gethashnode2;
468 optiontab->removenode = NULL;
469 optiontab->disablenode = disablehashnode;
470 optiontab->enablenode = enablehashnode;
471 optiontab->freenode = NULL;
472 optiontab->printnode = printoptionnode;
473
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
474 for (on = optns; on->node.nam; on++)
475 optiontab->addnode(optiontab, on->node.nam, on);
e74702b Initial revision
Tanaka Akira authored
476 }
477
478 /* Setting of default options */
479
480 /**/
481 static void
482 setemulate(HashNode hn, int fully)
483 {
484 Optname on = (Optname) hn;
485
486 /* Set options: each non-special option is set according to the *
487 * current emulation mode if either it is considered relevant *
488 * to emulation or we are doing a full emulation (as indicated *
489 * by the `fully' parameter). */
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
490 if (!(on->node.flags & OPT_ALIAS) &&
491 ((fully && !(on->node.flags & OPT_SPECIAL)) ||
492 (on->node.flags & OPT_EMULATE)))
e74702b Initial revision
Tanaka Akira authored
493 opts[on->optno] = defset(on);
494 }
495
496 /**/
497 void
c7d8b0d 26546, 26556: sticky emulation for functions defined in emulate ... -…
Peter Stephenson authored
498 installemulation(void)
499 {
500 scanhashtable(optiontab, 0, 0, 0, setemulate,
501 !!(emulation & EMULATE_FULLY));
502 }
503
504 /**/
505 void
e74702b Initial revision
Tanaka Akira authored
506 emulate(const char *zsh_name, int fully)
507 {
508 char ch = *zsh_name;
509
510 if (ch == 'r')
511 ch = zsh_name[1];
512
513 /* Work out the new emulation mode */
514 if (ch == 'c')
515 emulation = EMULATE_CSH;
516 else if (ch == 'k')
517 emulation = EMULATE_KSH;
518 else if (ch == 's' || ch == 'b')
519 emulation = EMULATE_SH;
520 else
521 emulation = EMULATE_ZSH;
522
c7d8b0d 26546, 26556: sticky emulation for functions defined in emulate ... -…
Peter Stephenson authored
523 if (fully)
524 emulation |= EMULATE_FULLY;
525 installemulation();
7614be7 30303: emulate inside function marked for execution tracing enables x…
Peter Stephenson authored
526
527 if (funcstack && funcstack->tp == FS_FUNC) {
528 /*
529 * We are inside a function. Decide if it's traced.
530 * Pedantic note: the function in the function table isn't
531 * guaranteed to be what we're executing, but it's
532 * close enough.
533 */
534 Shfunc shf = (Shfunc)shfunctab->getnode(shfunctab, funcstack->name);
535 if (shf && (shf->node.flags & PM_TAGGED)) {
536 /* Tracing is on, so set xtrace */
537 opts[XTRACE] = 1;
538 }
539 }
e74702b Initial revision
Tanaka Akira authored
540 }
541
542 /* setopt, unsetopt */
543
544 /**/
545 static void
546 setoption(HashNode hn, int value)
547 {
548 dosetopt(((Optname) hn)->optno, value, 0);
549 }
550
551 /**/
552 int
fb0937a Marked unused parameters with the new UNUSED() macro.
Wayne Davison authored
553 bin_setopt(char *nam, char **args, UNUSED(Options ops), int isun)
e74702b Initial revision
Tanaka Akira authored
554 {
555 int action, optno, match = 0;
556
557 /* With no arguments or options, display options. */
558 if (!*args) {
559 scanhashtable(optiontab, 1, 0, OPT_ALIAS, optiontab->printnode, !isun);
560 return 0;
561 }
562
563 /* loop through command line options (begins with "-" or "+") */
564 while (*args && (**args == '-' || **args == '+')) {
565 action = (**args == '-') ^ isun;
566 if(!args[0][1])
567 *args = "--";
568 while (*++*args) {
569 if(**args == Meta)
570 *++*args ^= 32;
571 /* The pseudo-option `--' signifies the end of options. */
572 if (**args == '-') {
573 args++;
574 goto doneoptions;
575 } else if (**args == 'o') {
576 if (!*++*args)
577 args++;
578 if (!*args) {
dd5602f 22474: use variable argument lists to improve error message handling
Peter Stephenson authored
579 zwarnnam(nam, "string expected after -o");
e74702b Initial revision
Tanaka Akira authored
580 inittyptab();
581 return 1;
582 }
583 if(!(optno = optlookup(*args)))
dd5602f 22474: use variable argument lists to improve error message handling
Peter Stephenson authored
584 zwarnnam(nam, "no such option: %s", *args);
e74702b Initial revision
Tanaka Akira authored
585 else if(dosetopt(optno, action, 0))
dd5602f 22474: use variable argument lists to improve error message handling
Peter Stephenson authored
586 zwarnnam(nam, "can't change option: %s", *args);
e74702b Initial revision
Tanaka Akira authored
587 break;
588 } else if(**args == 'm') {
589 match = 1;
590 } else {
591 if (!(optno = optlookupc(**args)))
dd5602f 22474: use variable argument lists to improve error message handling
Peter Stephenson authored
592 zwarnnam(nam, "bad option: -%c", **args);
e74702b Initial revision
Tanaka Akira authored
593 else if(dosetopt(optno, action, 0))
dd5602f 22474: use variable argument lists to improve error message handling
Peter Stephenson authored
594 zwarnnam(nam, "can't change option: -%c", **args);
e74702b Initial revision
Tanaka Akira authored
595 }
596 }
597 args++;
598 }
599 doneoptions:
600
601 if (!match) {
602 /* Not globbing the arguments -- arguments are simply option names. */
603 while (*args) {
604 if(!(optno = optlookup(*args++)))
dd5602f 22474: use variable argument lists to improve error message handling
Peter Stephenson authored
605 zwarnnam(nam, "no such option: %s", args[-1]);
e74702b Initial revision
Tanaka Akira authored
606 else if(dosetopt(optno, !isun, 0))
dd5602f 22474: use variable argument lists to improve error message handling
Peter Stephenson authored
607 zwarnnam(nam, "can't change option: %s", args[-1]);
e74702b Initial revision
Tanaka Akira authored
608 }
609 } else {
610 /* Globbing option (-m) set. */
611 while (*args) {
5c53fb9 10771: new GLOBAL_EXPORT option; successful compilation on OpenBSD
Peter Stephenson authored
612 Patprog pprog;
613 char *s, *t;
614
615 t = s = dupstring(*args);
616 while (*t)
617 if (*t == '_')
618 chuck(t);
619 else {
7fc8ddd 24301: missed a case for lower-casing options
Peter Stephenson authored
620 /* See comment in optlookup() */
621 if (*t >= 'A' && *t <= 'Z')
622 *t = (*t - 'A') + 'a';
5c53fb9 10771: new GLOBAL_EXPORT option; successful compilation on OpenBSD
Peter Stephenson authored
623 t++;
624 }
e74702b Initial revision
Tanaka Akira authored
625
626 /* Expand the current arg. */
5c53fb9 10771: new GLOBAL_EXPORT option; successful compilation on OpenBSD
Peter Stephenson authored
627 tokenize(s);
628 if (!(pprog = patcompile(s, PAT_STATIC, NULL))) {
dd5602f 22474: use variable argument lists to improve error message handling
Peter Stephenson authored
629 zwarnnam(nam, "bad pattern: %s", *args);
e74702b Initial revision
Tanaka Akira authored
630 continue;
631 }
632 /* Loop over expansions. */
0108088 23152: make ztrcmp() respect MULTIBYTE
Peter Stephenson authored
633 scanmatchtable(optiontab, pprog, 0, 0, OPT_ALIAS,
634 setoption, !isun);
e74702b Initial revision
Tanaka Akira authored
635 args++;
636 }
637 }
638 inittyptab();
639 return 0;
640 }
641
642 /* Identify an option name */
643
644 /**/
5c53fb9 10771: new GLOBAL_EXPORT option; successful compilation on OpenBSD
Peter Stephenson authored
645 mod_export int
e74702b Initial revision
Tanaka Akira authored
646 optlookup(char const *name)
647 {
648 char *s, *t;
649 Optname n;
650
651 s = t = dupstring(name);
652
653 /* exorcise underscores, and change to lowercase */
654 while (*t)
655 if (*t == '_')
656 chuck(t);
657 else {
ab29ab8 Fix lower casing of option names in some locales.
Peter Stephenson authored
658 /*
659 * Some locales (in particular tr_TR.UTF-8) may
660 * have non-standard mappings of ASCII characters,
661 * so be careful. Option names must be ASCII so
662 * we don't need to be too clever.
663 */
664 if (*t >= 'A' && *t <= 'Z')
665 *t = (*t - 'A') + 'a';
e74702b Initial revision
Tanaka Akira authored
666 t++;
667 }
668
669 /* look up name in the table */
670 if (s[0] == 'n' && s[1] == 'o' &&
671 (n = (Optname) optiontab->getnode(optiontab, s + 2))) {
672 return -n->optno;
673 } else if ((n = (Optname) optiontab->getnode(optiontab, s)))
674 return n->optno;
675 else
676 return OPT_INVALID;
677 }
678
679 /* Identify an option letter */
680
681 /**/
682 int
683 optlookupc(char c)
684 {
685 if(c < FIRST_OPT || c > LAST_OPT)
686 return 0;
687
688 return optletters[c - FIRST_OPT];
689 }
690
691 /**/
692 static void
693 restrictparam(char *nam)
694 {
695 Param pm = (Param) paramtab->getnode(paramtab, nam);
696
697 if (pm) {
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
698 pm->node.flags |= PM_SPECIAL | PM_RESTRICTED;
e74702b Initial revision
Tanaka Akira authored
699 return;
700 }
701 createparam(nam, PM_SCALAR | PM_UNSET | PM_SPECIAL | PM_RESTRICTED);
702 }
703
704 /* list of restricted parameters which are not otherwise special */
705 static char *rparams[] = {
706 "SHELL", "HISTFILE", "LD_LIBRARY_PATH", "LD_AOUT_LIBRARY_PATH",
707 "LD_PRELOAD", "LD_AOUT_PRELOAD", NULL
708 };
709
710 /* Set or unset an option, as a result of user request. The option *
711 * number may be negative, indicating that the sense is reversed *
712 * from the usual meaning of the option. */
713
714 /**/
5c53fb9 10771: new GLOBAL_EXPORT option; successful compilation on OpenBSD
Peter Stephenson authored
715 mod_export int
e74702b Initial revision
Tanaka Akira authored
716 dosetopt(int optno, int value, int force)
717 {
718 if(!optno)
719 return -1;
720 if(optno < 0) {
721 optno = -optno;
722 value = !value;
723 }
724 if (optno == RESTRICTED) {
725 if (isset(RESTRICTED))
726 return value ? 0 : -1;
727 if (value) {
728 char **s;
729
730 for (s = rparams; *s; s++)
731 restrictparam(*s);
732 }
3069706 Refuse to setopt noexec when interactive
Bart Schaefer authored
733 } else if(!force && optno == EXECOPT && !value && interact) {
734 /* cannot set noexec when interactive */
735 return -1;
e74702b Initial revision
Tanaka Akira authored
736 } else if(!force && (optno == INTERACTIVE || optno == SHINSTDIN ||
737 optno == SINGLECOMMAND)) {
5c53fb9 10771: new GLOBAL_EXPORT option; successful compilation on OpenBSD
Peter Stephenson authored
738 if (opts[optno] == value)
739 return 0;
e74702b Initial revision
Tanaka Akira authored
740 /* it is not permitted to change the value of these options */
741 return -1;
742 } else if(!force && optno == USEZLE && value) {
743 /* we require a terminal in order to use ZLE */
744 if(!interact || SHTTY == -1 || !shout)
745 return -1;
746 } else if(optno == PRIVILEGED && !value) {
747 /* unsetting PRIVILEGED causes the shell to make itself unprivileged */
748 #ifdef HAVE_SETUID
749 setuid(getuid());
750 setgid(getgid());
751 #endif /* HAVE_SETUID */
17001a7 22656: improve handling of monitor option
Peter Stephenson authored
752 #ifdef JOB_CONTROL
753 } else if (!force && optno == MONITOR && value) {
754 if (opts[optno] == value)
755 return 0;
b31ca21 27100: Allow MONITOR option in non-interactive shells for testing.
Peter Stephenson authored
756 if (SHTTY != -1) {
17001a7 22656: improve handling of monitor option
Peter Stephenson authored
757 origpgrp = GETPGRP();
758 acquire_pgrp();
759 } else
760 return -1;
761 #else
5c53fb9 10771: new GLOBAL_EXPORT option; successful compilation on OpenBSD
Peter Stephenson authored
762 } else if(optno == MONITOR && value) {
763 return -1;
764 #endif /* not JOB_CONTROL */
765 #ifdef GETPWNAM_FAKED
766 } else if(optno == CDABLEVARS && value) {
767 return -1;
768 #endif /* GETPWNAM_FAKED */
4e309d2 18539 and remaining bits of 18536???: vi and emacs options, autoload zle
Peter Stephenson authored
769 } else if ((optno == EMACSMODE || optno == VIMODE) && value) {
fa8a0e2 30320: "emulate" accepts invocation-time flags; other small doc tweaks.
Bart Schaefer authored
770 if (sticky_emulation)
771 return -1;
0c9830d 25345, 25347: neaten interface from main shell to zle
Peter Stephenson authored
772 zleentry(ZLE_CMD_SET_KEYMAP, optno);
4e309d2 18539 and remaining bits of 18536???: vi and emacs options, autoload zle
Peter Stephenson authored
773 opts[(optno == EMACSMODE) ? VIMODE : EMACSMODE] = 0;
036cb0c Joakim Rosqvist: 27591 as modified in 27594:
Peter Stephenson authored
774 } else if (optno == SUNKEYBOARDHACK) {
775 /* for backward compatibility */
776 keyboardhackchar = (value ? '`' : '\0');
e74702b Initial revision
Tanaka Akira authored
777 }
778 opts[optno] = value;
779 if (optno == BANGHIST || optno == SHINSTDIN)
780 inittyptab();
781 return 0;
782 }
783
784 /* Function to get value for special parameter `-' */
785
786 /**/
787 char *
fb0937a Marked unused parameters with the new UNUSED() macro.
Wayne Davison authored
788 dashgetfn(UNUSED(Param pm))
e74702b Initial revision
Tanaka Akira authored
789 {
790 static char buf[LAST_OPT - FIRST_OPT + 2];
791 char *val = buf;
792 int i;
793
794 for(i = 0; i <= LAST_OPT - FIRST_OPT; i++) {
795 int optno = optletters[i];
796 if(optno && ((optno > 0) ? isset(optno) : unset(-optno)))
797 *val++ = FIRST_OPT + i;
798 }
799 *val = '\0';
800 return buf;
801 }
9743c19 12434: Doc/Zsh/invoke.yo, Src/init.c, Src/options.c, Src/zsh.h,
Andrew Main authored
802
09c5818 18530: print option states with `set -o' or `set +o'
Oliver Kiddle authored
803 /* print options for set -o/+o */
804
805 /**/
806 void
807 printoptionstates(int hadplus)
808 {
809 scanhashtable(optiontab, 1, 0, OPT_ALIAS, printoptionnodestate, hadplus);
810 }
811
812 /**/
813 static void
814 printoptionnodestate(HashNode hn, int hadplus)
815 {
816 Optname on = (Optname) hn;
817 int optno = on->optno;
818
819 if (hadplus) {
820 if (defset(on) != isset(optno))
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
821 printf("set -o %s%s\n", defset(on) ? "no" : "", on->node.nam);
09c5818 18530: print option states with `set -o' or `set +o'
Oliver Kiddle authored
822 } else {
823 if (defset(on))
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
824 printf("no%-19s %s\n", on->node.nam, isset(optno) ? "off" : "on");
09c5818 18530: print option states with `set -o' or `set +o'
Oliver Kiddle authored
825 else
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
826 printf("%-21s %s\n", on->node.nam, isset(optno) ? "on" : "off");
09c5818 18530: print option states with `set -o' or `set +o'
Oliver Kiddle authored
827 }
828 }
829
9743c19 12434: Doc/Zsh/invoke.yo, Src/init.c, Src/options.c, Src/zsh.h,
Andrew Main authored
830 /* Print option list for --help */
831
832 /**/
833 void
834 printoptionlist(void)
835 {
836 short *lp;
837 char c;
838
839 printf("\nNamed options:\n");
840 scanhashtable(optiontab, 1, 0, OPT_ALIAS, printoptionlist_printoption, 0);
841 printf("\nOption aliases:\n");
842 scanhashtable(optiontab, 1, OPT_ALIAS, 0, printoptionlist_printoption, 0);
843 printf("\nOption letters:\n");
844 for(lp = optletters, c = FIRST_OPT; c <= LAST_OPT; lp++, c++) {
845 if(!*lp)
846 continue;
847 printf(" -%c ", c);
848 printoptionlist_printequiv(*lp);
849 }
850 }
851
852 /**/
853 static void
fb0937a Marked unused parameters with the new UNUSED() macro.
Wayne Davison authored
854 printoptionlist_printoption(HashNode hn, UNUSED(int ignored))
9743c19 12434: Doc/Zsh/invoke.yo, Src/init.c, Src/options.c, Src/zsh.h,
Andrew Main authored
855 {
856 Optname on = (Optname) hn;
857
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
858 if(on->node.flags & OPT_ALIAS) {
859 printf(" --%-19s ", on->node.nam);
9743c19 12434: Doc/Zsh/invoke.yo, Src/init.c, Src/options.c, Src/zsh.h,
Andrew Main authored
860 printoptionlist_printequiv(on->optno);
861 } else
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
862 printf(" --%s\n", on->node.nam);
9743c19 12434: Doc/Zsh/invoke.yo, Src/init.c, Src/options.c, Src/zsh.h,
Andrew Main authored
863 }
864
865 /**/
866 static void
867 printoptionlist_printequiv(int optno)
868 {
869 int isneg = optno < 0;
870
871 optno *= (isneg ? -1 : 1);
4cb8357 Changed some structures to avoid gcc's type-punned warnings.
Wayne Davison authored
872 printf(" equivalent to --%s%s\n", isneg ? "no-" : "", optns[optno-1].node.nam);
9743c19 12434: Doc/Zsh/invoke.yo, Src/init.c, Src/options.c, Src/zsh.h,
Andrew Main authored
873 }
Something went wrong with that request. Please try again.