tar: support -T - and -X -
[oweals/busybox.git] / libbb / execable.c
index 5c7ac16a2c16465e99b1f9f3fc5f9b35e36709a0..178a00a5f1f69a762c7f20e5b2dd852bcf2ae2b0 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Copyright (C) 2006 Gabriel Somlo <somlo at cmu.edu>
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  */
 
 #include "libbb.h"
@@ -68,11 +68,19 @@ int FAST_FUNC exists_execable(const char *filename)
 }
 
 #if ENABLE_FEATURE_PREFER_APPLETS
-/* just like the real execvp, but try to launch an applet named 'file' first
- */
-int FAST_FUNC bb_execvp(const char *file, char *const argv[])
+/* just like the real execvp, but try to launch an applet named 'file' first */
+int FAST_FUNC BB_EXECVP(const char *file, char *const argv[])
 {
-       return execvp(find_applet_by_name(file) >= 0 ? bb_busybox_exec_path : file,
-                                       argv);
+       if (find_applet_by_name(file) >= 0)
+               execvp(bb_busybox_exec_path, argv);
+       return execvp(file, argv);
 }
 #endif
+
+int FAST_FUNC BB_EXECVP_or_die(char **argv)
+{
+       BB_EXECVP(argv[0], argv);
+       /* SUSv3-mandated exit codes */
+       xfunc_error_retval = (errno == ENOENT) ? 127 : 126;
+       bb_perror_msg_and_die("can't execute '%s'", argv[0]);
+}