• R/O
  • SSH
  • HTTPS

yash: Commit


Commit MetaInfo

Revision3204 (tree)
Time2013-02-17 17:14:27
Authormagicant

Log Message

yash: yash: 初期化ファイル実行中は構文エラーでシェルを終了しないように (#30663)
+shell_initialized
parse_and_exec

Change Summary

Incremental Difference

--- yash/trunk/doc/ja/exec.txt (revision 3203)
+++ yash/trunk/doc/ja/exec.txt (revision 3204)
@@ -63,7 +63,7 @@
6363
6464 link:interact.html[対話モード]でないシェルの実行中に下記エラーが発生した場合、シェルは直ちに終了します。このときシェルの終了ステータスは非 0 です。
6565
66-- 文法エラーのためコマンドを解釈できないとき
66+- 文法エラーのためコマンドを解釈できないとき (link:invoke.html#init[シェルの初期化]中を除く)
6767 - link:posix.html[POSIX 準拠モード]で、link:builtin.html#types[特殊組込みコマンド]のオプションやオペランドの使い方が間違っているとき
6868 - POSIX 準拠モードで、特殊組込みコマンドに対してリダイレクトエラーまたは代入エラーが発生したとき
6969 - 展開エラーが発生したとき
--- yash/trunk/doc/exec.txt (revision 3203)
+++ yash/trunk/doc/exec.txt (revision 3204)
@@ -153,7 +153,8 @@
153153 If a non-link:interact.html[interactive] shell encountered one of the
154154 following errors, the shell immediately exits with a non-zero exit status:
155155
156-- A command cannot be parsed due to an syntax error.
156+- A command cannot be parsed due to an syntax error (except during
157+ link:invoke.html#init[shell initialization]).
157158 - A link:builtin.html#types[special built-in] is executed in the
158159 link:posix.html[POSIXly-correct mode] and the command arguments do not meet
159160 the syntax of the built-in's arguments.
--- yash/trunk/NEWS (revision 3203)
+++ yash/trunk/NEWS (revision 3204)
@@ -13,6 +13,8 @@
1313 + New "test" built-in operator: =~, -o (unary)
1414 + New completion scripts for:
1515 configure, git-name-rev, git-request-pull, make, rsync
16+ = A syntax error in .yash_profile or .yashrc no longer makes the
17+ shell exit even when the shell is not interactive.
1618 = In line-editing, overwritten characters are now restored when you
1719 hit the backspace key.
1820 = In line-editing, the undo history is no longer saved for each
--- yash/trunk/yash.c (revision 3203)
+++ yash/trunk/yash.c (revision 3204)
@@ -75,6 +75,9 @@
7575 * In a job-controlled subshell, this value is set to the subshell's pgid. */
7676 pid_t shell_pgid;
7777
78+/* Set to true when the shell has been initialized. */
79+bool shell_initialized;
80+
7881 /* If this flag is true when the "exit" built-in is invoked, the -f option is
7982 * assumed to be specified. */
8083 static bool forceexit;
@@ -232,6 +235,8 @@
232235 if (getuid() == geteuid() && getgid() == getegid())
233236 execute_rcfile(options.rcfile);
234237
238+ shell_initialized = true;
239+
235240 if (shopt_cmdline)
236241 exec_wcs(input.command, inputname, true);
237242 else
@@ -524,7 +529,7 @@
524529 }
525530 break;
526531 case PR_SYNTAX_ERROR:
527- if (!is_interactive_now)
532+ if (shell_initialized && !is_interactive_now)
528533 exit_shell_with_status(Exit_SYNERROR);
529534 if (!pinfo->interactive) {
530535 laststatus = Exit_SYNERROR;
--- yash/trunk/yash.h (revision 3203)
+++ yash/trunk/yash.h (revision 3204)
@@ -26,6 +26,8 @@
2626
2727 extern pid_t shell_pid, shell_pgid;
2828
29+extern _Bool shell_initialized;
30+
2931 static inline void exit_shell(void)
3032 __attribute__((noreturn));
3133 extern void exit_shell_with_status(int status)
Show on old repository browser