From 8679cd68d825bfe28ba0c833494c415bcfa6d8f6 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 8 Apr 2012 12:32:17 -0400 Subject: scripts/library: introduce parseopts This will replace our current options parser used in pacman-key, makepkg, and ideally elsewhere. It follows heuristics closer to that of GNU getopt long (and thus pacman itself), with the exception that it does not allow for options with optional arguments. Due to the way this parser will be used, this sort of functionality will not be needed. Instead of relying on eval+set, options are normalized into an array, OPTRET, which callers should expect to be populated after returning from parseopts. This avoids problems with quotes and spaces in arguments, assuming that the user quotes properly when passing into the application. A new test harness for parseopts is added in test/scripts. Signed-off-by: Dave Reisner --- scripts/Makefile.am | 1 + 1 file changed, 1 insertion(+) (limited to 'scripts/Makefile.am') diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 328fbff2..7662fba6 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -27,6 +27,7 @@ EXTRA_DIST = \ LIBRARY = \ library/output_format.sh \ + library/parseopts.sh \ library/parse_options.sh # Files that should be removed, but which Automake does not know. -- cgit v1.2.3 From d85c71865ee826041c85cd47189ea43b44ce52cc Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 8 Apr 2012 13:13:07 -0400 Subject: makepkg: adopt parseopts for option parsing Signed-off-by: Dave Reisner --- scripts/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/Makefile.am') diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 7662fba6..0df90e13 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -68,7 +68,7 @@ $(OURSCRIPTS): Makefile makepkg: \ $(srcdir)/makepkg.sh.in \ - $(srcdir)/library/parse_options.sh + $(srcdir)/library/parseopts.sh pacman-db-upgrade: \ $(srcdir)/pacman-db-upgrade.sh.in \ -- cgit v1.2.3 From f61f075b1cd4c226d1633abd383565934bea2f0d Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 8 Apr 2012 14:51:28 -0400 Subject: pacman-key: adopt parseopts for option parsing This requires an ugly amount of reworking of how pacman-key handles options. The change simply to avoid passing keys, files, and directories as arguments to options, but to leave them as arguments to the overall program. This is reasonable since pacman-key limits the user to essentially one operation per invocation (like pacman). Since we now pass around the positional parameters to the various operations, we can add some better sanity checking. Each operation is responsible for testing input and making sure it can operate properly, otherwise it throws an error and exits. The doc is updated to reflect this, and uses similar verbiage as pacman, describing the non-option arguments now passed to pacman-key as targets. Similar to the doc, --help is reorganized to separate operations and options and remove argument tokens from operations. Signed-off-by: Dave Reisner --- scripts/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/Makefile.am') diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 0df90e13..fc70732f 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -77,7 +77,7 @@ pacman-db-upgrade: \ pacman-key: \ $(srcdir)/pacman-key.sh.in \ $(srcdir)/library/output_format.sh \ - $(srcdir)/library/parse_options.sh + $(srcdir)/library/parseopts.sh pacman-optimize: \ $(srcdir)/pacman-optimize.sh.in \ -- cgit v1.2.3 From 00ab01e6342b7183d5a16ae57497b19dc1c2c7dc Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 8 Apr 2012 15:12:27 -0400 Subject: scripts/library: remove parse_options This is retired, as the two consumers of this function are now using the new parseopts instead. Signed-off-by: Dave Reisner --- scripts/Makefile.am | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'scripts/Makefile.am') diff --git a/scripts/Makefile.am b/scripts/Makefile.am index fc70732f..b8a19900 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -27,8 +27,7 @@ EXTRA_DIST = \ LIBRARY = \ library/output_format.sh \ - library/parseopts.sh \ - library/parse_options.sh + library/parseopts.sh # Files that should be removed, but which Automake does not know. MOSTLYCLEANFILES = $(bin_SCRIPTS) -- cgit v1.2.3