- Timestamp:
- Sep 9, 2012 3:47:26 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kash/exec.c
r2648 r2649 228 228 } 229 229 230 231 230 #ifdef EXEC_HASH_BANG_SCRIPT 231 232 /* 233 * Checks if NAME is the (base) name of the shell executable or something 234 * very similar. 235 */ 236 STATIC int 237 is_shell_exe_name(const char *name) 238 { 239 return equal(name, "kmk_ash") 240 || equal(name, "kmk_sh") 241 || equal(name, "kash") 242 || equal(name, "sh"); 243 } 244 232 245 /* 233 246 * Execute an interpreter introduced by "#!", for systems where this … … 277 290 } 278 291 279 /* if no args, maybe shell and no exec is needed. */ 280 if (ap == newargs + 1) { 292 /* Special optimizations / builtins. */ 293 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. */ 281 303 p = strrchr(newargs[0], '/'); 282 304 if (!p) 283 305 p = newargs[0]; 284 if ( equal(p, "kmk_ash") || equal(p, "kmk_sh") || equal(p, "kash") || equal(p, "sh")) {306 if (is_shell_exe_name(p)) { 285 307 TRACE((psh, "hash bang self\n")); 286 308 return; … … 288 310 } 289 311 312 /* Combine the argument lists and exec. */ 290 313 i = (char *)ap - (char *)newargs; /* size in bytes */ 291 314 if (i == 0) … … 297 320 *ap2++ = *ap++; 298 321 ap = argv; 299 while (*ap2++ = *ap++); 322 while ((*ap2++ = *ap++)) 323 /* nothing*/; 300 324 TRACE((psh, "hash bang '%s'\n", new[0])); 301 325 shellexec(psh, new, envp, pathval(psh), 0, 0); 302 326 /* NOTREACHED */ 303 327 } 304 #endif 305 328 329 #endif /* EXEC_HASH_BANG_SCRIPT */ 306 330 307 331
Note:
See TracChangeset
for help on using the changeset viewer.