aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-04-12 21:31:32 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-04-12 21:31:32 +0200
commit6c149f4d9afaed9edb75c88b784ad900c1f40700 (patch)
tree1cf5c3800fa0e87fb8f30cee951eaa65a54378a6
parente139ae307e4fd9eb3b86a6fc2e97b4e212925199 (diff)
downloadbusybox-w32-6c149f4d9afaed9edb75c88b784ad900c1f40700.tar.gz
busybox-w32-6c149f4d9afaed9edb75c88b784ad900c1f40700.tar.bz2
busybox-w32-6c149f4d9afaed9edb75c88b784ad900c1f40700.zip
ash: implement "exec -a ARGV0 CMD ARGV1..."
function old new delta execcmd 71 112 +41 shellexec 221 224 +3 evalcommand 1158 1161 +3 localcmd 364 366 +2 unaliascmd 163 154 -9 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/1 up/down: 49/-9) Total: 40 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/ash.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 044f166be..e170bec2a 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -3345,11 +3345,9 @@ unaliascmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
3345{ 3345{
3346 int i; 3346 int i;
3347 3347
3348 while ((i = nextopt("a")) != '\0') { 3348 while (nextopt("a") != '\0') {
3349 if (i == 'a') { 3349 rmaliases();
3350 rmaliases(); 3350 return 0;
3351 return 0;
3352 }
3353 } 3351 }
3354 for (i = 0; *argptr; argptr++) { 3352 for (i = 0; *argptr; argptr++) {
3355 if (unalias(*argptr)) { 3353 if (unalias(*argptr)) {
@@ -9354,7 +9352,14 @@ truecmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
9354static int FAST_FUNC 9352static int FAST_FUNC
9355execcmd(int argc UNUSED_PARAM, char **argv) 9353execcmd(int argc UNUSED_PARAM, char **argv)
9356{ 9354{
9357 if (argv[1]) { 9355 optionarg = NULL;
9356 while (nextopt("a:") != '\0')
9357 /* nextopt() sets optionarg to "-a ARGV0" */;
9358
9359 argv = argptr;
9360 if (argv[0]) {
9361 char *prog;
9362
9358 iflag = 0; /* exit on error */ 9363 iflag = 0; /* exit on error */
9359 mflag = 0; 9364 mflag = 0;
9360 optschanged(); 9365 optschanged();
@@ -9370,7 +9375,10 @@ execcmd(int argc UNUSED_PARAM, char **argv)
9370 /*setsignal(SIGTSTP); - unnecessary because of mflag=0 */ 9375 /*setsignal(SIGTSTP); - unnecessary because of mflag=0 */
9371 /*setsignal(SIGTTOU); - unnecessary because of mflag=0 */ 9376 /*setsignal(SIGTTOU); - unnecessary because of mflag=0 */
9372 9377
9373 shellexec(argv[1], argv + 1, pathval(), 0); 9378 prog = argv[0];
9379 if (optionarg)
9380 argv[0] = optionarg;
9381 shellexec(prog, argv, pathval(), 0);
9374 /* NOTREACHED */ 9382 /* NOTREACHED */
9375 } 9383 }
9376 return 0; 9384 return 0;