Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: symlink chain.



On 01/03/2015 04:40 PM, Bart Schaefer wrote:
My actual view is closer to the pocketknife than to the wrench.  The
-w and -s options of whence can be useful with a full path.  The -m
option just isn't that sort of blade.

I think the core of the difference between our points of view, is that for me, it's a simple question of trying to maximize consistency and minimize surprise. For you, knowing the guts of how these things work, it is intuitive/obvious that -m should do what it does, and not work with full paths, whereas for me, not knowing that stuff, I take the more superficial view and don't want -m killing a search that would work fine without it. I expect -m to *just* *add* the ability to search for patterns, not to kill otherwise acceptable searches. When I know how this hash table works, I will probably come round to your way of viewing it.
Don't use the knife with both ends unfolded and then complain when you
stab yourself in the thumb.


Well, one analogy is as good as another.  With so many of these issues, it
comes down to how you look at it.  For me, switches add features, they
don't invalidate arguments ... but is that really a rule? ...
However, if you REALLY want the -m option to do something special with
arguments that start with a slash, you need this (which I won't commit):


As we were saying it's not really about the slash, I'd say it's more a test for an existing, specific file, no? FWIW, this is how I handle it now:


     local ma=ma
      [ -e $1 ] && ma=
      find_count=`whence -$ma "$nnocase$1" | wc -l`

... pretty sad, IMHO, I do what whence should do for me, and cut out the -ma when they are going to sabotage the output. Anyway, it works fine, it just bugs me.


I hafta learn how to do this patching (I don't want to blow something up doing it wrong) and I have to learn how to ask git to preserve any local changes while still pulling whatever needs to be pulled. (Most cool that it can do that sort of thing at all.) You can't sneak anything past git, that's for sure.


diff --git a/Src/builtin.c b/Src/builtin.c
index ebc0654..509629f 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3243,10 +3243,28 @@ bin_whence(char *nam, char **argv, Options ops, int func)
  	    }
  	    /* Done search for `internal' commands, if the -p option *
  	     * was not used.  Now search the path.                   */
-	    cmdnamtab->filltable(cmdnamtab);
-	    scanmatchtable(cmdnamtab, pprog, 1, 0, 0,
-			   (all ? fetchcmdnamnode : cmdnamtab->printnode),
-			   printflags);
+	    if (**argv == '/') {
+		if (all)
+		    addlinknode(matchednodes, *argv);
+		else if ((cnam = findcmd(*argv, 1))) {
+		    /* Found external command. */
+		    if (wd) {
+			printf("%s: command\n", *argv);
+		    } else {
+			if (v && !csh)
+			    zputs(*argv, stdout), fputs(" is ", stdout);
+			zputs(cnam, stdout);
+			if (OPT_ISSET(ops,'s') || OPT_ISSET(ops,'S'))
+			    print_if_link(cnam, OPT_ISSET(ops,'S'));
+			fputc('\n', stdout);
+		    }
+		}
+	    } else {
+		cmdnamtab->filltable(cmdnamtab);
+		scanmatchtable(cmdnamtab, pprog, 1, 0, 0,
+			       (all ? fetchcmdnamnode : cmdnamtab->printnode),
+			       printflags);
+	    }
unqueue_signals();
  	}




Messages sorted by: Reverse Date, Date, Thread, Author