aboutsummaryrefslogtreecommitdiff
path: root/q.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2014-03-21 01:28:35 -0400
committerMike Frysinger <vapier@gentoo.org>2014-03-21 01:28:35 -0400
commit214d027f0d92d1d042451765e875f0a84c3fa37d (patch)
treede0b57ddca10e6d8f78a400962ef3604f6855e4b /q.c
parentqpkg: document the chdir() usage (diff)
downloadportage-utils-214d027f0d92d1d042451765e875f0a84c3fa37d.tar.gz
portage-utils-214d027f0d92d1d042451765e875f0a84c3fa37d.tar.bz2
portage-utils-214d027f0d92d1d042451765e875f0a84c3fa37d.zip
which: punt!
This code is only used by --install, and only when /proc/self/exe does not work. We rarely utilize --install, and it's rare for /proc to be broken in a way we can't rely on. So having this func just for that does not make much sense. Even then, the code was not correct. It walked $PATH in reverse order (when it should have been forward order), and it would abort scanning beofre it checked the first element. It also doesn't support empty path elements (which is supposed to be $PWD). If we want a which() in the future, we can grab the updated version from Gentoo's pax-utils project.
Diffstat (limited to 'q.c')
-rw-r--r--q.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/q.c b/q.c
index 394a035c..443ce4be 100644
--- a/q.c
+++ b/q.c
@@ -104,15 +104,10 @@ int q_main(int argc, char **argv)
rret = readlink("/proc/self/exe", buf, sizeof(buf) - 1);
if (rret == -1) {
- char *ptr = which("q");
- if (ptr == NULL) {
- warnfp("haha no symlink love for you");
- return 1;
- }
- strncpy(buf, ptr, sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
- } else
- buf[rret] = '\0';
+ warnfp("haha no symlink love for you");
+ return 1;
+ }
+ buf[rret] = '\0';
prog = basename(buf);
dir = dirname(buf);