私のプロジェクトのテスト範囲は20%しかありません。 https://coveralls.io/github/montao/opsh
構文エラーのテストを追加したい。単純なoneliner Shellコマンドから出力「構文エラー」を受け取ることができません。いくつかの例を教えていただけますか?
;
返却値:
bash: syntax error near unexpected token `;'
bash
の予約語と制御演算子の大部分を使用して、構文エラーを引き起こすことができます。リストを取得するための簡単なテストを行いましょう(もちろん不完全です!)。
$ 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 `]]'
man bash
/DEFINITIONS および / RESERVED WORDS から取得しました。