• R/O
  • SSH
  • HTTPS

yash: 提交


Commit MetaInfo

修訂4129 (tree)
時間2020-11-02 23:08:18
作者magicant

Log Message

Correct job name

Change Summary

差異

--- yash/branches/exec/exec.c (revision 4128)
+++ yash/branches/exec/exec.c (revision 4129)
@@ -182,9 +182,9 @@
182182 __attribute__((nonnull));
183183 static void exec_nonsimple_command(command_T *c, bool finally_exit)
184184 __attribute__((nonnull));
185-static void invoke_simple_command(const commandinfo_T *ci,
185+static wchar_t **invoke_simple_command(const commandinfo_T *ci,
186186 int argc, char *argv0, void **argv, bool finally_exit)
187- __attribute__((nonnull));
187+ __attribute__((nonnull,warn_unused_result));
188188 static void exec_external_program(
189189 const char *path, int argc, char *argv0, void **argv, char **envs)
190190 __attribute__((nonnull));
@@ -926,9 +926,10 @@
926926 }
927927
928928 /* execute! */
929- invoke_simple_command(&cmdinfo, argc, argv0, argv,
929+ wchar_t **namep = invoke_simple_command(&cmdinfo, argc, argv0, argv,
930930 finally_exit && /* !temp && */ savefd == NULL);
931- // TODO refactor invoke_simple_command
931+ if (namep != NULL)
932+ *namep = command_to_wcs(c, false);
932933
933934 /* Redirections are not undone after a successful "exec" command:
934935 * remove the saved data of file descriptors. */
@@ -1259,12 +1260,14 @@
12591260
12601261 /* Invokes the simple command. */
12611262 /* `argv0' is the multibyte version of `argv[0]' */
1262-void invoke_simple_command(
1263+wchar_t **invoke_simple_command(
12631264 const commandinfo_T *ci, int argc, char *argv0, void **argv,
12641265 bool finally_exit)
12651266 {
12661267 assert(plcount(argv) == (size_t) argc);
12671268
1269+ fork_and_wait_T faw = { 0, NULL };
1270+
12681271 switch (ci->type) {
12691272 case CT_NONE:
12701273 xerror(0, Ngt("no such command `%s'"), argv0);
@@ -1272,12 +1275,9 @@
12721275 break;
12731276 case CT_EXTERNALPROGRAM:
12741277 if (!finally_exit) {
1275- fork_and_wait_T faw = fork_and_wait(t_leave);
1276- if (faw.cpid != 0) {
1277- if (faw.namep != NULL)
1278- *faw.namep = joinwcsarray(argv, L" ");
1278+ faw = fork_and_wait(t_leave);
1279+ if (faw.cpid != 0)
12791280 break;
1280- }
12811281 finally_exit = true;
12821282 }
12831283 exec_external_program(ci->ci_path, argc, argv0, argv, environ);
@@ -1300,6 +1300,7 @@
13001300 }
13011301 if (finally_exit)
13021302 exit_shell();
1303+ return faw.namep;
13031304 }
13041305
13051306 /* Executes the external program.
@@ -2343,7 +2344,11 @@
23432344 }
23442345
23452346 search_command(argv0, argv[0], &ci, type);
2346- invoke_simple_command(&ci, argc, argv0, argv, false);
2347+
2348+ wchar_t **namep = invoke_simple_command(&ci, argc, argv0, argv, false);
2349+ if (namep != NULL)
2350+ *namep = joinwcsarray(argv, L" ");
2351+
23472352 free(argv0);
23482353 return laststatus;
23492354 }
Show on old repository browser