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

Re: symlink chain.



On Jan 3,  1:13pm, Ray Andrews wrote:
} Subject: Re: symlink chain.
}
} On 01/03/2015 12:02 PM, Bart Schaefer wrote:
} >
} > Whence is a pocketknife that you seem to want to be a Leatherman tool.
} >
} > If you want the wrench analogy, wrenches fit on nuts, and nuts of a
} > particular shape.
}
} Well sir, you've made up your mind on that, so I won't flog the subject 
} further, but to say that if:
} 
}       $ whence /usr/bin/zsh
} 
} ... did *not* work. I'd have an easier time accepting your view.

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.

Don't use the knife with both ends unfolded and then complain when you
stab yourself in the thumb.

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):

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