Commit Diff


commit - f6eb52baa944180134f8d515007da159090fa5d2
commit + 444134c06cbc0ad8b7366aba187ea98566b758a5
blob - 7d771aecb5d74acb2b75f635b6d2b242448eb42a
blob + e3a2faba7bbc29b9f4aabf953849d7af19c066a1
--- cmdargs.c
+++ cmdargs.c
@@ -54,6 +54,13 @@ cmdargs(char *cmd, char *arg[])
 int
 cmdargs_output(char *cmd, char *arg[], int stdoutfd, int stderrfd)
 {
+	return cmdargs_output_setenv(cmd, arg, stdoutfd, stderrfd, NULL);
+}
+
+int
+cmdargs_output_setenv(char *cmd, char *arg[], int stdoutfd, int stderrfd,
+    char **env)
+{
 	sig_t sigint, sigquit, sigchld;
 	int status = -1;
 
@@ -94,8 +101,11 @@ cmdargs_output(char *cmd, char *arg[], int stdoutfd, i
 				}
 			}
 
-			execv(shellp, arg);
-			printf("%% execv failed: %s\n", strerror(errno));
+			if (env)
+				execvpe(shellp, arg, env);
+			else
+				execv(shellp, arg);
+			printf("%% exec failed: %s\n", strerror(errno));
 			_exit(127); /* same as what ksh(1) would do here */
 		}
 			break;
blob - a1f2ecea9d8252e146f3e086eba407199cdc685d
blob + 98be4c1f2a50bf22257eacd7a22db984d21c26e7
--- externs.h
+++ externs.h
@@ -149,6 +149,7 @@ extern char metricnames[];
 /* ctl.c declarations moved to ctl.h */
 
 /* cmdargs.c */
+int cmdargs_output_setenv(char *, char **, int, int, char **);
 int cmdargs_output(char *, char **, int, int);
 int cmdargs(char *, char **);
 int nsh_setrtable(int);