tftpd: new applet (mostly using existing code for tftp)
[oweals/busybox.git] / libbb / execable.c
index cb56b91816513d2dd289a1ae0801d1405dfc70dd..2649a6cfe62a9f09bb1ab584c48b97843c8b8906 100644 (file)
@@ -27,7 +27,7 @@ char *find_execable(const char *filename)
 {
        char *path, *p, *n;
 
-       p = path = xstrdup(getenv("PATH") ? : "");
+       p = path = xstrdup(getenv("PATH"));
        while (p) {
                n = strchr(p, ':');
                if (n)
@@ -60,3 +60,12 @@ int exists_execable(const char *filename)
        return 0;
 }
 
+#if ENABLE_FEATURE_PREFER_APPLETS
+/* just like the real execvp, but try to launch an applet named 'file' first
+ */
+int bb_execvp(const char *file, char *const argv[])
+{
+       return execvp(find_applet_by_name(file) >= 0 ? bb_busybox_exec_path : file,
+                                       argv);
+}
+#endif