summaryrefslogtreecommitdiff
path: root/Src/options.c
diff options
context:
space:
mode:
authorAndrew Main <zefram@users.sourceforge.net>2000-07-30 17:03:52 +0000
committerAndrew Main <zefram@users.sourceforge.net>2000-07-30 17:03:52 +0000
commit9743c19d618056b3af1f5efe887a1e8a9944e27b (patch)
treebb365c62ee0ad1f1a3ba0d1eb9ae2074fb8832bc /Src/options.c
parentb7c6421796248d747f8cf0cad42f06969a2bc907 (diff)
downloadzsh-9743c19d618056b3af1f5efe887a1e8a9944e27b.tar.gz
zsh-9743c19d618056b3af1f5efe887a1e8a9944e27b.zip
12434: Doc/Zsh/invoke.yo, Src/init.c, Src/options.c, Src/zsh.h,
Src/zsh.mdd: Allow options to be specified on the zsh command line in the form of GNU-style long options. Also handle --version and --help. Do not permit extra option letters to be stacked after `-whatever-' (they used to be ignored). Exit if the command line specifies an option name that doesn't exist.
Diffstat (limited to 'Src/options.c')
-rw-r--r--Src/options.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/Src/options.c b/Src/options.c
index ea3bf13de..0bbe6b844 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -694,3 +694,48 @@ dashgetfn(Param pm)
*val = '\0';
return buf;
}
+
+/* Print option list for --help */
+
+/**/
+void
+printoptionlist(void)
+{
+ short *lp;
+ char c;
+
+ printf("\nNamed options:\n");
+ scanhashtable(optiontab, 1, 0, OPT_ALIAS, printoptionlist_printoption, 0);
+ printf("\nOption aliases:\n");
+ scanhashtable(optiontab, 1, OPT_ALIAS, 0, printoptionlist_printoption, 0);
+ printf("\nOption letters:\n");
+ for(lp = optletters, c = FIRST_OPT; c <= LAST_OPT; lp++, c++) {
+ if(!*lp)
+ continue;
+ printf(" -%c ", c);
+ printoptionlist_printequiv(*lp);
+ }
+}
+
+/**/
+static void
+printoptionlist_printoption(HashNode hn, int ignored)
+{
+ Optname on = (Optname) hn;
+
+ if(on->flags & OPT_ALIAS) {
+ printf(" --%-19s ", on->nam);
+ printoptionlist_printequiv(on->optno);
+ } else
+ printf(" --%s\n", on->nam);
+}
+
+/**/
+static void
+printoptionlist_printequiv(int optno)
+{
+ int isneg = optno < 0;
+
+ optno *= (isneg ? -1 : 1);
+ printf(" equivalent to --%s%s\n", isneg ? "no-" : "", optns[optno-1].nam);
+}