+static char *getbin(const char *progname)
+{
+ char name[PATH_MAX];
+ char *path;
+ int i;
+
+ if (progname[0] == '/')
+ return access(progname, X_OK) ? NULL : strdup(progname);
+
+ path = getenv("PATH");
+ while(path && *path) {
+ for (i = 0 ; path[i] && path[i] != ':' ; i++)
+ name[i] = path[i];
+ path += i + !!path[i];
+ name[i] = '/';
+ strcpy(name + i + 1, progname);
+ if (access(name, X_OK) == 0)
+ return realpath(name, NULL);
+ }
+ return NULL;
+}
+
+static int zrun(const char *name, const char *args[])