;
retorna:
bash: syntax error near unexpected token ';'
Eu só tenho 20% de cobertura de teste para o meu projeto. link
Eu quero adicionar um teste para erro de sintaxe. Não consigo receber a saída "erro de sintaxe" de um comando shell oneliner simples. Você poderia me ajudar com alguns exemplos?
;
retorna:
bash: syntax error near unexpected token ';'
Você pode usar a grande maioria das palavras reservadas e operadores de controle de bash
para provocar um erro de sintaxe - vamos fazer um teste rápido para obter uma lista (obviamente incompleta!):
$ tabs 10
for i in '|' '&' ';' '(' ')' '<' '>' '||' '&&' \
';;' '|&' 'case' 'coproc' 'do' 'done' \
'elif' 'else' 'esac' 'fi' 'for' 'function' \
'if' 'in' 'select' 'then' 'until' 'while' \
'{' '}' '[[' ']]';
do
printf "%s\t" "$i"; bash -c $i |& sed '2d;s/.*://'
done
| syntax error near unexpected token '|'
& syntax error near unexpected token '&'
; syntax error near unexpected token ';'
( unexpected end of file
) syntax error near unexpected token ')'
< syntax error near unexpected token 'newline'
> syntax error near unexpected token 'newline'
|| syntax error near unexpected token '||'
&& syntax error near unexpected token '&&'
;; syntax error near unexpected token ';;'
|& syntax error near unexpected token '|&'
case syntax error near unexpected token 'newline'
coproc syntax error near unexpected token 'newline'
do syntax error near unexpected token 'do'
done syntax error near unexpected token 'done'
elif syntax error near unexpected token 'elif'
else syntax error near unexpected token 'else'
esac syntax error near unexpected token 'esac'
fi syntax error near unexpected token 'fi'
for syntax error near unexpected token 'newline'
function syntax error near unexpected token 'newline'
if unexpected end of file
in syntax error near unexpected token 'in'
select syntax error near unexpected token 'newline'
then syntax error near unexpected token 'then'
until unexpected end of file
while unexpected end of file
{ unexpected end of file
} syntax error near unexpected token '}'
[[ unexpected token 'EOF' in conditional command
]] syntax error near unexpected token ']]'
Eu peguei os de man bash
/ DEFINITIONS e < href="http://manpages.ubuntu.com/manpages/xenial/en/man1/bash.1.html#contenttoc8"> / PALAVRAS RESERVADAS .