mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-27 14:45:13 +08:00
Fix bug where 'else if' does not support functions and redirections
https://github.com/fish-shell/fish-shell/issues/359
This commit is contained in:
parent
8c24d49c73
commit
7bb844a778
12
parser.cpp
12
parser.cpp
@ -1309,11 +1309,13 @@ job_t *parser_t::job_get_from_pid( int pid )
|
|||||||
\param j the job to which the process belongs to
|
\param j the job to which the process belongs to
|
||||||
\param tok the tokenizer to read options from
|
\param tok the tokenizer to read options from
|
||||||
\param args the argument list to insert options into
|
\param args the argument list to insert options into
|
||||||
|
\param args unskip whether we should ignore current_block->skip. Big hack because of our dumb handling of if statements.
|
||||||
*/
|
*/
|
||||||
void parser_t::parse_job_argument_list( process_t *p,
|
void parser_t::parse_job_argument_list( process_t *p,
|
||||||
job_t *j,
|
job_t *j,
|
||||||
tokenizer *tok,
|
tokenizer *tok,
|
||||||
std::vector<completion_t> &args )
|
std::vector<completion_t> &args,
|
||||||
|
bool unskip )
|
||||||
{
|
{
|
||||||
int is_finished=0;
|
int is_finished=0;
|
||||||
|
|
||||||
@ -1401,7 +1403,7 @@ void parser_t::parse_job_argument_list( process_t *p,
|
|||||||
{
|
{
|
||||||
skip = 1;
|
skip = 1;
|
||||||
}
|
}
|
||||||
else if( current_block->skip )
|
else if( current_block->skip && ! unskip )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
If this command should be skipped, we do not expand the arguments
|
If this command should be skipped, we do not expand the arguments
|
||||||
@ -1505,7 +1507,7 @@ void parser_t::parse_job_argument_list( process_t *p,
|
|||||||
Otherwise, bogus errors may be the result. (Do check
|
Otherwise, bogus errors may be the result. (Do check
|
||||||
that token is string, though)
|
that token is string, though)
|
||||||
*/
|
*/
|
||||||
if( current_block->skip )
|
if( current_block->skip && ! unskip )
|
||||||
{
|
{
|
||||||
tok_next( tok );
|
tok_next( tok );
|
||||||
if( tok_last_type( tok ) != TOK_STRING )
|
if( tok_last_type( tok ) != TOK_STRING )
|
||||||
@ -1965,7 +1967,7 @@ int parser_t::parse_job( process_t *p,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( use_function && !current_block->skip )
|
if( use_function && ( unskip || ! current_block->skip ))
|
||||||
{
|
{
|
||||||
bool nxt_forbidden=false;
|
bool nxt_forbidden=false;
|
||||||
wcstring forbid;
|
wcstring forbid;
|
||||||
@ -2267,7 +2269,7 @@ int parser_t::parse_job( process_t *p,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
parse_job_argument_list(p, j, tok, args);
|
parse_job_argument_list(p, j, tok, args, unskip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
parser.h
2
parser.h
@ -333,7 +333,7 @@ class parser_t {
|
|||||||
parser_t(const parser_t&);
|
parser_t(const parser_t&);
|
||||||
parser_t& operator=(const parser_t&);
|
parser_t& operator=(const parser_t&);
|
||||||
|
|
||||||
void parse_job_argument_list( process_t *p, job_t *j, tokenizer *tok, std::vector<completion_t>& );
|
void parse_job_argument_list( process_t *p, job_t *j, tokenizer *tok, std::vector<completion_t>&, bool );
|
||||||
int parse_job( process_t *p, job_t *j, tokenizer *tok );
|
int parse_job( process_t *p, job_t *j, tokenizer *tok );
|
||||||
void skipped_exec( job_t * j );
|
void skipped_exec( job_t * j );
|
||||||
void eval_job( tokenizer *tok );
|
void eval_job( tokenizer *tok );
|
||||||
|
@ -102,3 +102,11 @@ else if not_a_valid_command but it should be OK because a previous branch was ta
|
|||||||
else if test ! -n "abc"
|
else if test ! -n "abc"
|
||||||
echo "epsilon 5.4"
|
echo "epsilon 5.4"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Ensure builtins work
|
||||||
|
# https://github.com/fish-shell/fish-shell/issues/359
|
||||||
|
if not echo skip1 > /dev/null
|
||||||
|
echo "zeta 6.1"
|
||||||
|
else if echo skip2 > /dev/null
|
||||||
|
echo "zeta 6.2"
|
||||||
|
end
|
||||||
|
@ -24,3 +24,4 @@ yep4.2
|
|||||||
delta4.1
|
delta4.1
|
||||||
delta4.2
|
delta4.2
|
||||||
epsilon5.2
|
epsilon5.2
|
||||||
|
zeta 6.2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user