• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

シェルスクリプト言語xyzshのソースコード。


Commit MetaInfo

修訂219e30081f1c57d0df8328383d59588bedda6b95 (tree)
時間2012-11-08 13:23:09
作者ab25q <ab25cq@gmai...>
Commiterab25q

Log Message

v1.1.8b

Change Summary

差異

--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,10 @@
11
2+2012 8th Norvember version 1.1.8b
3+
4+ Changed "exit -force" action for mfiler4.
5+
6+ Modified job title more better.
7+
28 2012 5th Norvember version 1.1.8a
39
410 Fixed errror message.
--- a/completion.xyzsh
+++ b/completion.xyzsh
@@ -125,6 +125,6 @@ completion git (
125125 )
126126
127127 completion kill (
128- ps | selector | split | lines 1 (|print)
128+ ps | each ( | sub '^\s+' '' ) | selector | split | lines 0 (|print)
129129 )
130130
--- a/src/block.c
+++ b/src/block.c
@@ -149,6 +149,36 @@ void sCommand_sweep_runtime_info(sCommand* self)
149149 }
150150 }
151151
152+void sStatment_sweep_runtime_info(sStatment* self)
153+{
154+ int j;
155+ for(j=0; j<self->mCommandsNum; j++) {
156+ sCommand* command = self->mCommands + j;
157+
158+ int i;
159+ for(i=0; i<command->mArgsNumRuntime; i++) {
160+ FREE(command->mArgsRuntime[i]);
161+ }
162+ command->mArgsNumRuntime = 0;
163+
164+ for(i=0; i<XYZSH_OPTION_MAX; i++) {
165+ if(command->mOptions[i].mKey) { FREE(command->mOptions[i].mKey); }
166+ if(command->mOptions[i].mArg) { FREE(command->mOptions[i].mArg); }
167+ }
168+
169+ memset(command->mOptions, 0, sizeof(option_hash_it)*XYZSH_OPTION_MAX);
170+
171+ if(command->mRedirectsFileNamesRuntime) {
172+ for(i=0; i<command->mRedirectsNum; i++) {
173+ FREE(command->mRedirectsFileNamesRuntime[i]);
174+ }
175+ FREE(command->mRedirectsFileNamesRuntime);
176+
177+ command->mRedirectsFileNamesRuntime = NULL;
178+ }
179+ }
180+}
181+
152182 void sCommand_add_redirect_to_command(sCommand* self, MANAGED char* name, int redirect)
153183 {
154184 if(self->mRedirectsNum >= self->mRedirectsSize) {
--- a/src/cmd_base.c
+++ b/src/cmd_base.c
@@ -32,7 +32,7 @@ BOOL cmd_jobs(sObject* nextin, sObject* nextout, sRunInfo* runinfo)
3232 int i;
3333 for(i=0; i<vector_count(gJobs); i++) {
3434 sObject* job = vector_item(gJobs, i);
35- int size = snprintf(buf, BUFSIZ, "[%d] name: %s pid&pgrp: %d", i+1, SJOB(job).mName, SJOB(job).mPGroup);
35+ int size = snprintf(buf, BUFSIZ, "[%d] %s (pgrp: %d)", i+1, SJOB(job).mName, SJOB(job).mPGroup);
3636 if(!fd_write(nextout, buf, size)) {
3737 err_msg("signal interrupt", runinfo->mSName, runinfo->mSLine, command->mArgs[0]);
3838 runinfo->mRCode = RCODE_SIGNAL_INTERRUPT;
@@ -82,8 +82,6 @@ BOOL cmd_exit(sObject* nextin, sObject* nextout, sRunInfo* runinfo)
8282 sCommand* command = runinfo->mCommand;
8383
8484 if(sCommand_option_item(command, "-force")) {
85- xyzsh_kill_all_jobs();
86-
8785 runinfo->mRCode = RCODE_EXIT;
8886 }
8987 else {
--- a/src/cmd_curses.c
+++ b/src/cmd_curses.c
@@ -127,9 +127,7 @@ BOOL cmd_selector(sObject* nextin, sObject* nextout, sRunInfo* runinfo)
127127 fd_split(nextin, lf);
128128
129129 if(vector_count(SFD(nextin).fdbuf.mLines) > 0) {
130-#if !defined(__FREEBSD__)
131130 msave_screen();
132-#endif
133131 msave_ttysettings();
134132 minitscr();
135133
@@ -235,9 +233,7 @@ BOOL cmd_selector(sObject* nextin, sObject* nextout, sRunInfo* runinfo)
235233 }
236234 else if(key == 'q' || key == 3 | key == 27 || key == 7) {
237235 mendwin();
238-#if !defined(__FREEBSD__)
239236 mrestore_screen();
240-#endif
241237 mrestore_ttysettings();
242238 FREE(markfiles);
243239 return FALSE;
@@ -329,9 +325,7 @@ BOOL cmd_selector(sObject* nextin, sObject* nextout, sRunInfo* runinfo)
329325 FREE(markfiles);
330326
331327 mendwin();
332-#if !defined(__FREEBSD__)
333328 mrestore_screen();
334-#endif
335329 mrestore_ttysettings();
336330 }
337331 else {
@@ -409,9 +403,7 @@ BOOL cmd_p(sObject* nextin, sObject* nextout, sRunInfo* runinfo)
409403 fd_split(nextin2, lf);
410404
411405 msave_ttysettings();
412-#if !defined(__FREEBSD__)
413406 msave_screen();
414-#endif
415407 minitscr();
416408
417409 const int maxx = mgetmaxx();
@@ -517,9 +509,7 @@ BOOL cmd_p(sObject* nextin, sObject* nextout, sRunInfo* runinfo)
517509 else if(key == 'q' || key == 3 | key == 27 || key == 7) {
518510 err_msg("p: canceled", runinfo->mSName, runinfo->mSLine, command->mArgs[0]);
519511 mendwin();
520-#if !defined(__FREEBSD__)
521512 mrestore_screen();
522-#endif
523513 mrestore_ttysettings();
524514 FREE(markfiles);
525515 return FALSE;
@@ -571,9 +561,7 @@ BOOL cmd_p(sObject* nextin, sObject* nextout, sRunInfo* runinfo)
571561 FREE(markfiles);
572562
573563 mendwin();
574-#if !defined(__FREEBSD__)
575564 mrestore_screen();
576-#endif
577565 mrestore_ttysettings();
578566 }
579567
@@ -971,9 +959,7 @@ BOOL cmd_fselector(sObject* nextin, sObject* nextout, sRunInfo* runinfo)
971959
972960 if(vector_count(v) > 0) {
973961 msave_ttysettings(); // 端末の設定の保存
974-#if !defined(__FREEBSD__)
975962 msave_screen();
976-#endif
977963 minitscr();
978964
979965 const int maxx = mgetmaxx();
@@ -1107,9 +1093,7 @@ BOOL cmd_fselector(sObject* nextin, sObject* nextout, sRunInfo* runinfo)
11071093 else if(key == 'q' || key == 3 | key == 27 || key == 7) {
11081094 err_msg("canceled", runinfo->mSName, runinfo->mSLine, command->mArgs[0]);
11091095 mendwin();
1110-#if !defined(__FREEBSD__)
11111096 mrestore_screen();
1112-#endif
11131097 mrestore_ttysettings(); // 端末の設定の復帰
11141098 int i;
11151099 for(i=0; i<vector_count(v); i++) {
@@ -1170,9 +1154,7 @@ BOOL cmd_fselector(sObject* nextin, sObject* nextout, sRunInfo* runinfo)
11701154 //mclear();
11711155 //mrefresh();
11721156 mendwin();
1173-#if !defined(__FREEBSD__)
11741157 mrestore_screen();
1175-#endif
11761158 mrestore_ttysettings(); // 端末の設定の復帰
11771159
11781160 if(vector_count(mark_files) == 0) {
--- a/src/curses.c
+++ b/src/curses.c
@@ -386,9 +386,6 @@ void mclear_online(int y)
386386 mmvprintw(y, 0, space);
387387 }
388388
389-
390-
391-
392389 void mmove(int y, int x)
393390 {
394391 gX = x;
@@ -1895,18 +1892,32 @@ int mis_raw_mode()
18951892
18961893 void msave_screen()
18971894 {
1895+#if defined(__FREEBSD__)
1896+#else
18981897 char* str = tigetstr("smcup");
18991898 if(str) {
19001899 ttywrite(str);
19011900 }
1901+ str = tigetstr("sc");
1902+ if(str) {
1903+ ttywrite(str);
1904+ }
1905+#endif
19021906 }
19031907
19041908 void mrestore_screen()
19051909 {
1910+#if defined(__FREEBSD__)
1911+#else
19061912 char* str = tigetstr("rmcup");
19071913 if(str) {
19081914 ttywrite(str);
19091915 }
1916+ str = tigetstr("rc");
1917+ if(str) {
1918+ ttywrite(str);
1919+ }
1920+#endif
19101921 }
19111922
19121923
--- a/src/interface.c
+++ b/src/interface.c
@@ -158,11 +158,12 @@ static void readline_insert_text(char* cmdline, int cursor_point)
158158
159159 rl_point = n;
160160
161+/*
161162 #if defined(__FREEBSD__)
162-//extern int rl_reset_terminal PARAMS((const char *));
163- mclear_immediately();
163+ puts("");
164164 rl_forced_update_display();
165165 #endif
166+*/
166167 }
167168
168169 static char* gCmdLine;
--- a/src/main.c
+++ b/src/main.c
@@ -38,7 +38,6 @@ int main(int argc, char** argv)
3838 }
3939 }
4040
41-
4241 if(optc) {
4342 xyzsh_init(kATOptC, no_runtime_script);
4443 xyzsh_opt_c(optc, argv, argc);
@@ -51,6 +50,7 @@ int main(int argc, char** argv)
5150 setenv("XYZSH_RUNNING_AS_INTRACTIVE_MODE", "1", 1);
5251 xyzsh_init(kATConsoleApp, no_runtime_script);
5352 xyzsh_readline_interface("", -1, argv, argc);
53+ xyzsh_kill_all_jobs();
5454 }
5555
5656 xyzsh_final();
--- a/src/readline.c
+++ b/src/readline.c
@@ -802,11 +802,8 @@ BOOL cmd_readline_insert_text(sObject* nextin, sObject* nextout, sRunInfo* runin
802802
803803 if(runinfo->mFilter) {
804804 (void)rl_insert_text(SFD(nextin).fdbuf.mBuf);
805-#if defined(__FREEBSD__)
806-//extern int rl_reset_terminal PARAMS((const char *));
807- mclear_immediately();
808- rl_forced_update_display();
809-#endif
805+ puts("");
806+ rl_forced_update_display();
810807
811808 runinfo->mRCode = 0;
812809 }
@@ -829,10 +826,8 @@ BOOL cmd_readline_delete_text(sObject* nextin, sObject* nextout, sRunInfo* runin
829826 if(rl_point < 0) {
830827 rl_point = 0;
831828 }
832-#if defined(__FREEBSD__)
833- mclear_immediately();
834- rl_forced_update_display();
835-#endif
829+ puts("");
830+ rl_forced_update_display();
836831
837832 runinfo->mRCode = 0;
838833 }
@@ -912,15 +907,13 @@ static int readline_macro(int count, int key)
912907 }
913908
914909 rl_insert_text(SFD(nextout2).fdbuf.mBuf);
915-#if defined(__FREEBSD__)
916- mclear_immediately();
910+ puts("");
917911 rl_forced_update_display();
918-#endif
919-
920912 stack_end_stack();
921913
922914 return 0;
923915 }
916+
924917 static int skip_quoted(const char *s, int i, char q)
925918 {
926919 while(s[i] && s[i]!=q)
--- a/src/run.c
+++ b/src/run.c
@@ -429,6 +429,34 @@ static void nextin_writer(pid_t pid, sObject* nextin, int* pipeinfds, int* pipeo
429429 *nextin_reader_pid = pid2;
430430 }
431431
432+void make_job_title(sStatment* statment, sCommand* command_, char* title, int title_num)
433+{
434+ title[0] = 0;
435+
436+ int i;
437+ for(i=0; i<statment->mCommandsNum; i++) {
438+ sCommand* command = statment->mCommands + i;
439+
440+ int j;
441+ for(j=0; j<command->mArgsNumRuntime; j++) {
442+ char* arg = command->mArgsRuntime[j];
443+
444+ xstrncat(title, arg, BUFSIZ);
445+ if(j+1 < command->mArgsNumRuntime) {
446+ xstrncat(title, " ", BUFSIZ);
447+ }
448+ }
449+
450+ if(command == command_) {
451+ break;
452+ }
453+
454+ if(i+1 < statment->mCommandsNum) {
455+ xstrncat(title, "|", BUFSIZ);
456+ }
457+ }
458+}
459+
432460 static BOOL wait_child_program(pid_t pid, pid_t nextin_reader_pid, int nextout2, sRunInfo* runinfo, char* program)
433461 {
434462 if(nextin_reader_pid != -1) {
@@ -522,14 +550,9 @@ static BOOL wait_child_program(pid_t pid, pid_t nextin_reader_pid, int nextout2,
522550 struct termios tty;
523551 tcgetattr(STDIN_FILENO, &tty);
524552
525- sStatment* statment = runinfo->mStatment;
526553 char title[BUFSIZ];
527- title[0] = 0;
528- int i;
529- for(i=0; i<statment->mCommandsNum; i++) {
530- xstrncat(title, statment->mCommands[i].mArgsRuntime[0], BUFSIZ);
531- xstrncat(title, " ", BUFSIZ);
532- }
554+ make_job_title(runinfo->mStatment, runinfo->mCommand, title, BUFSIZ);
555+
533556 sObject* job = JOB_NEW_GC(title, pid, tty);
534557 }
535558
@@ -586,14 +609,9 @@ static BOOL wait_child_program(pid_t pid, pid_t nextin_reader_pid, int nextout2,
586609 struct termios tty;
587610 tcgetattr(STDIN_FILENO, &tty);
588611
589- sStatment* statment = runinfo->mStatment;
590612 char title[BUFSIZ];
591- title[0] = 0;
592- int i;
593- for(i=0; i<statment->mCommandsNum; i++) {
594- xstrncat(title, statment->mCommands[i].mArgsRuntime[0], BUFSIZ);
595- xstrncat(title, " ", BUFSIZ);
596- }
613+ make_job_title(runinfo->mStatment, runinfo->mCommand, title, BUFSIZ);
614+
597615 sObject* job = JOB_NEW_GC(title, pid, tty);
598616 }
599617
@@ -1152,6 +1170,15 @@ static void redirect_finish(int opend_fd)
11521170
11531171 static BOOL statment_tree(sStatment* statment, sObject* pipein, sObject* pipeout, sRunInfo* runinfo, sObject* current_object)
11541172 {
1173+ /// error check ///
1174+ if(statment->mFlags & STATMENT_BACKGROUND) {
1175+ if(gAppType == kATOptC) {
1176+ err_msg("can't make a job background on script mode. you can make a job background on interactive shell", runinfo->mSName, runinfo->mSLine, NULL);
1177+ return FALSE;
1178+ }
1179+ }
1180+
1181+ /// head of statment ///
11551182 sObject* nextin;
11561183 if(statment->mFlags & STATMENT_CONTEXTPIPE) {
11571184 /// read stdin ///
@@ -1218,6 +1245,7 @@ static BOOL statment_tree(sStatment* statment, sObject* pipein, sObject* pipeout
12181245 nextin = pipein;
12191246 }
12201247
1248+ /// command loop ///
12211249 int i;
12221250 for(i=0; i<statment->mCommandsNum; i++) {
12231251 sCommand* command = runinfo->mCommand = statment->mCommands + i;
@@ -1409,7 +1437,6 @@ static BOOL statment_tree(sStatment* statment, sObject* pipein, sObject* pipeout
14091437 }
14101438 }
14111439 }
1412- sCommand_sweep_runtime_info(command);
14131440 }
14141441
14151442 if(opened_fd != -1) redirect_finish(opened_fd);
@@ -1422,6 +1449,8 @@ static BOOL statment_tree(sStatment* statment, sObject* pipein, sObject* pipeout
14221449 }
14231450 }
14241451
1452+ sStatment_sweep_runtime_info(statment);
1453+
14251454 /// reverse the return code ///
14261455 if(statment->mFlags & STATMENT_REVERSE) {
14271456 runinfo->mRCode = !runinfo->mRCode;
--- a/src/xyzsh.c
+++ b/src/xyzsh.c
@@ -112,7 +112,7 @@ static void xyzsh_read_rc()
112112
113113 void xyzsh_init(enum eAppType app_type, BOOL no_runtime_script)
114114 {
115- setenv("XYZSH_VERSION", "1.1.8a", 1);
115+ setenv("XYZSH_VERSION", "1.1.8b", 1);
116116 setenv("XYZSH_DATAROOTDIR", DATAROOTDIR, 1);
117117
118118 stack_init(1);;
--- a/src/xyzsh/xyzsh.h
+++ b/src/xyzsh/xyzsh.h
@@ -764,6 +764,7 @@ BOOL sCommand_put_option_with_argument(sCommand* self, MANAGED char* key, MANAGE
764764 BOOL sCommand_expand_env(sCommand* command, sObject* object, sObject* nextin, sObject* nextout, sRunInfo* runinfo);
765765 BOOL sCommand_expand_env_redirect(sCommand* command, sObject* nextin, sRunInfo* runinfo);
766766 void sCommand_sweep_runtime_info(sCommand* command);
767+void sStatment_sweep_runtime_info(sStatment* self);
767768
768769 extern sObject* gMemChecker;
769770