Changeset 2652 for trunk/src/kash/exec.c
- Timestamp:
- Sep 9, 2012, 7:21:48 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kash/exec.c
r2649 r2652 265 265 char **ap; 266 266 char *newargs[NEWARGS]; 267 int i;267 intptr_t i; 268 268 char **ap2; 269 269 char **new; 270 270 271 /* Split the string into arguments. */ 271 272 n = psh->parsenleft - 2; 272 273 inp = psh->parsenextc + 2; … … 290 291 } 291 292 292 /* Special optimizations / builtins. */293 /* /usr/bin/env emulation, very common with kash/kmk_ash. */ 293 294 i = ap - newargs; 294 if (i > 1 && equal(newargs[0], "/usr/bin/env")) { 295 /* /usr/bin/env <self> -> easy. */ 296 if (i == 2 && is_shell_exe_name(newargs[1])) { 297 TRACE((psh, "hash bang /usr/bin/env self\n")); 298 return; 299 } 300 /** @todo implement simple /usr/bin/env that locates an exec in the PATH. */ 301 302 } else if (i == 1) { /* if no args, maybe shell and no exec is needed. */ 295 if (i > 1 && equal(newargs[0], "/usr/bin/env")) { 296 if ( !strchr(newargs[1], '=') 297 && newargs[1][0] != '-') { 298 /* shellexec below searches the PATH for us, so just 299 drop /usr/bin/env. */ 300 TRACE((psh, "hash bang /usr/bin/env utility, dropping /usr/bin/env\n")); 301 ap--; 302 i--; 303 for (n = 0; n < i; n++) 304 newargs[n] = newargs[n + 1]; 305 } /* else: complicated invocation */ 306 } 307 308 /* If the interpreter is the shell or a similar shell, there is 309 no need to exec. */ 310 if (i == 1) { 303 311 p = strrchr(newargs[0], '/'); 304 312 if (!p) … … 310 318 } 311 319 312 /* Combine the argument lists and exec. */320 /* Combine the two argument lists and exec. */ 313 321 i = (char *)ap - (char *)newargs; /* size in bytes */ 314 322 if (i == 0)
Note:
See TracChangeset
for help on using the changeset viewer.