diff --git a/builtin.c b/builtin.c index e407c9765..4b30dce07 100644 --- a/builtin.c +++ b/builtin.c @@ -2476,7 +2476,7 @@ static int builtin_begin( wchar_t **argv ) { parser_push_block( BEGIN ); current_block->tok_pos = parser_get_pos(); - return 0; + return proc_get_last_status(); } diff --git a/doc_src/begin.txt b/doc_src/begin.txt index b955376de..07ef10e0d 100644 --- a/doc_src/begin.txt +++ b/doc_src/begin.txt @@ -13,6 +13,8 @@ into a block. The reason for this is usually either to introduce a new variable scope or to redirect the input to output of this set of commands as a group. +The \c begin command does not change the current exit status. + \subsection begin-example Example The following code sets a number of variables inside of a block diff --git a/doc_src/end.txt b/doc_src/end.txt index b98aef822..3b61e9d35 100644 --- a/doc_src/end.txt +++ b/doc_src/end.txt @@ -13,4 +13,4 @@ begin; [COMMANDS...] end documentation for the block constructs, such as \c if, \c for and \ while. -The end command does not change the current exit status. +The \c end command does not change the current exit status.