Correct job name
@@ -182,9 +182,9 @@ | ||
182 | 182 | __attribute__((nonnull)); |
183 | 183 | static void exec_nonsimple_command(command_T *c, bool finally_exit) |
184 | 184 | __attribute__((nonnull)); |
185 | -static void invoke_simple_command(const commandinfo_T *ci, | |
185 | +static wchar_t **invoke_simple_command(const commandinfo_T *ci, | |
186 | 186 | int argc, char *argv0, void **argv, bool finally_exit) |
187 | - __attribute__((nonnull)); | |
187 | + __attribute__((nonnull,warn_unused_result)); | |
188 | 188 | static void exec_external_program( |
189 | 189 | const char *path, int argc, char *argv0, void **argv, char **envs) |
190 | 190 | __attribute__((nonnull)); |
@@ -926,9 +926,10 @@ | ||
926 | 926 | } |
927 | 927 | |
928 | 928 | /* execute! */ |
929 | - invoke_simple_command(&cmdinfo, argc, argv0, argv, | |
929 | + wchar_t **namep = invoke_simple_command(&cmdinfo, argc, argv0, argv, | |
930 | 930 | finally_exit && /* !temp && */ savefd == NULL); |
931 | - // TODO refactor invoke_simple_command | |
931 | + if (namep != NULL) | |
932 | + *namep = command_to_wcs(c, false); | |
932 | 933 | |
933 | 934 | /* Redirections are not undone after a successful "exec" command: |
934 | 935 | * remove the saved data of file descriptors. */ |
@@ -1259,12 +1260,14 @@ | ||
1259 | 1260 | |
1260 | 1261 | /* Invokes the simple command. */ |
1261 | 1262 | /* `argv0' is the multibyte version of `argv[0]' */ |
1262 | -void invoke_simple_command( | |
1263 | +wchar_t **invoke_simple_command( | |
1263 | 1264 | const commandinfo_T *ci, int argc, char *argv0, void **argv, |
1264 | 1265 | bool finally_exit) |
1265 | 1266 | { |
1266 | 1267 | assert(plcount(argv) == (size_t) argc); |
1267 | 1268 | |
1269 | + fork_and_wait_T faw = { 0, NULL }; | |
1270 | + | |
1268 | 1271 | switch (ci->type) { |
1269 | 1272 | case CT_NONE: |
1270 | 1273 | xerror(0, Ngt("no such command `%s'"), argv0); |
@@ -1272,12 +1275,9 @@ | ||
1272 | 1275 | break; |
1273 | 1276 | case CT_EXTERNALPROGRAM: |
1274 | 1277 | 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) | |
1279 | 1280 | break; |
1280 | - } | |
1281 | 1281 | finally_exit = true; |
1282 | 1282 | } |
1283 | 1283 | exec_external_program(ci->ci_path, argc, argv0, argv, environ); |
@@ -1300,6 +1300,7 @@ | ||
1300 | 1300 | } |
1301 | 1301 | if (finally_exit) |
1302 | 1302 | exit_shell(); |
1303 | + return faw.namep; | |
1303 | 1304 | } |
1304 | 1305 | |
1305 | 1306 | /* Executes the external program. |
@@ -2343,7 +2344,11 @@ | ||
2343 | 2344 | } |
2344 | 2345 | |
2345 | 2346 | 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 | + | |
2347 | 2352 | free(argv0); |
2348 | 2353 | return laststatus; |
2349 | 2354 | } |