svn commit: [25997] trunk/busybox/shell: hush_test/hush-misc
vda at busybox.net
vda at busybox.net
Mon Apr 6 18:40:31 UTC 2009
Author: vda
Date: 2009-04-06 18:40:31 +0000 (Mon, 06 Apr 2009)
New Revision: 25997
Log:
hush: fix "if false; then...fi" exitcode;
trim "keyword"-less hush by 10 bytes
Added:
trunk/busybox/shell/hush_test/hush-misc/if_false_exitcode.right
trunk/busybox/shell/hush_test/hush-misc/if_false_exitcode.tests
Modified:
trunk/busybox/shell/hush.c
Changeset:
Modified: trunk/busybox/shell/hush.c
===================================================================
--- trunk/busybox/shell/hush.c 2009-04-06 18:10:20 UTC (rev 25996)
+++ trunk/busybox/shell/hush.c 2009-04-06 18:40:31 UTC (rev 25997)
@@ -3038,8 +3038,10 @@
#else
enum { cond_code = 0 };
#endif
+#if HAS_KEYWORDS
smallint rword; /* enum reserved_style */
smallint last_rword; /* ditto */
+#endif
debug_printf_exec("run_list start lvl %d\n", G.run_list_level + 1);
@@ -3118,10 +3120,12 @@
}
#endif /* JOB */
- rcode = G.last_return_code;
+#if HAS_KEYWORDS
rword = RES_NONE;
last_rword = RES_XXXX;
+#endif
last_followup = PIPE_SEQ;
+ rcode = G.last_return_code;
/* Go through list of pipes, (maybe) executing them. */
for (; pi; pi = USE_HUSH_LOOPS(rword == RES_DONE ? loop_top : ) pi->next) {
@@ -3129,7 +3133,6 @@
break;
IF_HAS_KEYWORDS(rword = pi->res_word;)
- IF_HAS_NO_KEYWORDS(rword = RES_NONE;)
debug_printf_exec(": rword=%d cond_code=%d last_rword=%d\n",
rword, cond_code, last_rword);
#if ENABLE_HUSH_LOOPS
@@ -3142,7 +3145,7 @@
}
#endif
/* Still in the same "if...", "then..." or "do..." branch? */
- if (rword == last_rword) {
+ if (IF_HAS_KEYWORDS(rword == last_rword &&) 1) {
if ((rcode == 0 && last_followup == PIPE_OR)
|| (rcode != 0 && last_followup == PIPE_AND)
) {
@@ -3154,10 +3157,12 @@
}
}
last_followup = pi->followup;
- last_rword = rword;
+ IF_HAS_KEYWORDS(last_rword = rword;)
#if ENABLE_HUSH_IF
if (cond_code) {
if (rword == RES_THEN) {
+ /* if false; then ... fi has exitcode 0! */
+ G.last_return_code = rcode = EXIT_SUCCESS;
/* "if <false> THEN cmd": skip cmd */
continue;
}
Added: trunk/busybox/shell/hush_test/hush-misc/if_false_exitcode.right
===================================================================
--- trunk/busybox/shell/hush_test/hush-misc/if_false_exitcode.right (rev 0)
+++ trunk/busybox/shell/hush_test/hush-misc/if_false_exitcode.right 2009-04-06 18:40:31 UTC (rev 25997)
@@ -0,0 +1 @@
+Ok:0
Added: trunk/busybox/shell/hush_test/hush-misc/if_false_exitcode.tests
===================================================================
--- trunk/busybox/shell/hush_test/hush-misc/if_false_exitcode.tests (rev 0)
+++ trunk/busybox/shell/hush_test/hush-misc/if_false_exitcode.tests 2009-04-06 18:40:31 UTC (rev 25997)
@@ -0,0 +1,2 @@
+if false; then echo Bad; fi
+echo Ok:$?
Property changes on: trunk/busybox/shell/hush_test/hush-misc/if_false_exitcode.tests
___________________________________________________________________
Added: svn:executable
+ *
More information about the busybox-cvs
mailing list