[PATCH] exec: hashcmd: don't early-exit when first -r is found

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This fixes incorrectly-accepted "hash -rv" being equivalent to hash -r
(well, hash -r[literally anything] being equivalent to hash -r)

Also remove -v from the manual, it doesn't appear to have ever existed

Fixes: https://bugs.debian.org/819829
---
 src/dash.1 | 6 ++----
 src/exec.c | 8 +++++++-
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/dash.1 b/src/dash.1
index ff02237..3e09090 100644
--- a/src/dash.1
+++ b/src/dash.1
@@ -1441,7 +1441,8 @@ cmd \-a \-c arg file file
 cmd \-carg -a file file
 cmd \-a \-carg \-\- file file
 .Ed
-.It hash Fl rv Ar command ...
+.It hash Op Ar command ...
+.It hash Fl r
 The shell maintains a hash table which remembers the
 locations of commands.
 With no arguments whatsoever,
@@ -1457,9 +1458,6 @@ With arguments, the
 .Ic hash
 command removes the specified commands from the hash table (unless
 they are functions) and then locates them.
-With the
-.Fl v
-option, hash prints the locations of the commands as it finds them.
 The
 .Fl r
 option causes the hash command to delete all the entries in the hash table
diff --git a/src/exec.c b/src/exec.c
index 87354d4..d7a1f53 100644
--- a/src/exec.c
+++ b/src/exec.c
@@ -36,6 +36,7 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <stdbool.h>
 #include <stdlib.h>
 #ifdef HAVE_PATHS_H
 #include <paths.h>
@@ -271,11 +272,16 @@ hashcmd(int argc, char **argv)
 	int c;
 	struct cmdentry entry;
 	char *name;
+	bool clear;
 
-	while ((c = nextopt("r")) != '\0') {
+	clear = false;
+	while ((c = nextopt("r")) != '\0')
+		clear = true;
+	if(clear) {
 		clearcmdentry();
 		return 0;
 	}
+
 	if (*argptr == NULL) {
 		for (pp = cmdtable ; pp < &cmdtable[CMDTABLESIZE] ; pp++) {
 			for (cmdp = *pp ; cmdp ; cmdp = cmdp->next) {
-- 
2.30.2

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux