シェルスクリプト言語xyzshのソースコード。
修订版 | 148a5fba9e977e191e6b2bc26e80f4354bfe8855 (tree) |
---|---|
时间 | 2012-11-05 11:52:23 |
作者 | ab25cq <ab25cq@gmai...> |
Commiter | ab25cq |
1.1.8a
@@ -1,4 +1,8 @@ | ||
1 | 1 | |
2 | +2012 5th Norvember version 1.1.8a | |
3 | + | |
4 | + Fixed errror message. | |
5 | + | |
2 | 6 | 2012 30th Octorber version 1.1.8 |
3 | 7 | |
4 | 8 | Added -index option to "add" inner command and "del" inner command. |
@@ -1130,7 +1130,7 @@ static BOOL expand_env_to_command(ALLOC char** result, char* str, sCommand* comm | ||
1130 | 1130 | |
1131 | 1131 | if(!run(env->mBlock, nextin, nextout, &rcode, runinfo->mCurrentObject, runinfo->mRunningObject)) |
1132 | 1132 | { |
1133 | - err_msg("run time error", runinfo->mSName, runinfo->mSLine, command->mArgs[0]); | |
1133 | + err_msg_adding("run time error", runinfo->mSName, runinfo->mSLine, command->mArgs[0]); | |
1134 | 1134 | runinfo->mRCode = rcode; |
1135 | 1135 | FREE(buf.mBuf); |
1136 | 1136 | return FALSE; |
@@ -561,6 +561,22 @@ static BOOL wait_child_program(pid_t pid, pid_t nextin_reader_pid, int nextout2, | ||
561 | 561 | /// exited normally /// |
562 | 562 | else if(WIFEXITED(status)) { |
563 | 563 | runinfo->mRCode = WEXITSTATUS(status); |
564 | + | |
565 | + /// command not found /// | |
566 | + if(runinfo->mRCode == 127) { | |
567 | + if(gAppType == kATConsoleApp) // && nextout2 == 1) | |
568 | + { | |
569 | + if(tcsetpgrp(0, getpgid(0)) < 0) { | |
570 | + perror("tcsetpgrp(xyzsh)"); | |
571 | + exit(1); | |
572 | + } | |
573 | + } | |
574 | + | |
575 | + char buf[BUFSIZ]; | |
576 | + snprintf(buf, BUFSIZ, "command not found"); | |
577 | + err_msg(buf, runinfo->mSName, runinfo->mSLine, program); | |
578 | + return FALSE; | |
579 | + } | |
564 | 580 | } |
565 | 581 | /// stopped from signal /// |
566 | 582 | else if(WIFSTOPPED(status)) { |
@@ -644,15 +660,13 @@ static BOOL run_exec_cprog(sCommand* command, char* program, int nextin, int nex | ||
644 | 660 | if(program_at_cd) { |
645 | 661 | if(access(program, X_OK) == 0) { |
646 | 662 | fprintf(stderr, "This is program at current directory\n"); |
647 | - kill(getppid(), SIGUSR1); | |
648 | - exit(1); | |
663 | + exit(127); | |
649 | 664 | } |
650 | 665 | } |
651 | 666 | |
652 | 667 | execv(program, command->mArgsRuntime); |
653 | 668 | //fprintf(stderr, "exec('%s') error\n", command->mArgsRuntime[0]); // comment out for try |
654 | - kill(getppid(), SIGUSR1); | |
655 | - exit(1); | |
669 | + exit(127); | |
656 | 670 | } |
657 | 671 | |
658 | 672 | static BOOL run_external_command(char* program, sObject* nextin, sObject* nextout, sRunInfo* runinfo) |
@@ -112,7 +112,7 @@ static void xyzsh_read_rc() | ||
112 | 112 | |
113 | 113 | void xyzsh_init(enum eAppType app_type, BOOL no_runtime_script) |
114 | 114 | { |
115 | - setenv("XYZSH_VERSION", "1.1.8", 1); | |
115 | + setenv("XYZSH_VERSION", "1.1.8a", 1); | |
116 | 116 | setenv("XYZSH_DATAROOTDIR", DATAROOTDIR, 1); |
117 | 117 | |
118 | 118 | stack_init(1);; |