Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Annlix
ShellCheck
提交
b060370b
S
ShellCheck
项目概览
Annlix
/
ShellCheck
与 Fork 源项目一致
Fork自
镜像 / koalaman / ShellCheck
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
ShellCheck
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b060370b
编写于
7月 03, 2013
作者:
V
Vidar Holen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added and improved parse warnings for missing spaces.
上级
f557ac33
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
29 addition
and
11 deletion
+29
-11
ShellCheck/Parser.hs
ShellCheck/Parser.hs
+29
-11
未找到文件。
ShellCheck/Parser.hs
浏览文件 @
b060370b
...
...
@@ -60,9 +60,17 @@ prop_allspacing = isOk allspacing "#foo"
prop_allspacing2
=
isOk
allspacing
" #foo
\n
# bar
\n
#baz
\n
"
prop_allspacing3
=
isOk
allspacing
"#foo
\n
#bar
\n
#baz
\n
"
allspacing
=
do
spacing
x
<-
option
False
(
linefeed
>>
return
True
)
when
x
allspacing
s
<-
spacing
more
<-
option
False
(
linefeed
>>
return
True
)
if
more
then
do
rest
<-
allspacing
return
$
s
++
"
\n
"
++
rest
else
return
s
allspacingOrFail
=
do
s
<-
allspacing
when
(
null
s
)
$
fail
"Expected spaces"
carriageReturn
=
do
parseNote
ErrorC
"Literal carriage return. Run script through tr -d '
\\
r' ."
...
...
@@ -1066,10 +1074,11 @@ readSimpleCommand = called "simple command" $ do
return
$
makeSimpleCommand
id1
id2
(
prefix
++
cmd
++
suffix
)
prop_readPipeline
=
isOk
readPipeline
"! cat /etc/issue | grep -i ubuntu"
prop_readPipeline2
=
isWarning
readPipeline
"!cat /etc/issue | grep -i ubuntu"
readPipeline
=
do
unexpecting
"keyword/token"
readKeyword
do
(
T_Bang
id
)
<-
g_Bang
`
thenSkip
`
spacing
(
T_Bang
id
)
<-
g_Bang
pipe
<-
readPipeSequence
return
$
T_Banged
id
pipe
<|>
do
...
...
@@ -1091,7 +1100,7 @@ readTerm' current =
do
id
<-
getNextId
sep
<-
readSeparator
more
<-
(
option
(
T_EOF
id
)
$
readAndOr
)
more
<-
(
option
(
T_EOF
id
)
readAndOr
)
case
more
of
(
T_EOF
_
)
->
return
[
transformWithSeparator
id
sep
current
]
_
->
do
list
<-
readTerm'
more
...
...
@@ -1197,13 +1206,19 @@ readSubshell = called "explicit subshell" $ do
return
$
T_Subshell
id
list
prop_readBraceGroup
=
isOk
readBraceGroup
"{ a; b | c | d; e; }"
prop_readBraceGroup2
=
isWarning
readBraceGroup
"{foo;}"
readBraceGroup
=
called
"brace group"
$
do
id
<-
getNextId
char
'{'
allspacing
allspacingOrFail
<|>
parseProblem
ErrorC
"You need a space after the '{'."
optional
$
do
pos
<-
getPosition
lookAhead
$
char
'}'
parseProblemAt
pos
ErrorC
"You need at least one command here. Use 'true;' as a no-op."
list
<-
readTerm
allspacing
char
'}'
char
'}'
<|>
do
parseProblem
ErrorC
"Expected a '}'. If you have one, try a ; or
\\
n in front of it."
fail
"Unable to parse"
return
$
T_BraceGroup
id
list
prop_readWhileClause
=
isOk
readWhileClause
"while [[ -e foo ]]; do sleep 1; done"
...
...
@@ -1342,7 +1357,7 @@ readFunctionDefinition = called "function" $ do
id
<-
getNextId
name
<-
try
readFunctionSignature
allspacing
(
disregard
(
lookAhead
g_Lbrace
)
<|>
parseProblem
ErrorC
"Expected a { to open the function definition."
)
(
disregard
(
lookAhead
$
char
'{'
)
<|>
parseProblem
ErrorC
"Expected a { to open the function definition."
)
group
<-
readBraceGroup
return
$
T_Function
id
name
group
...
...
@@ -1393,7 +1408,6 @@ readCompoundCommand = do
lookAhead
$
try
(
spacing
>>
needsSeparator
)
parseProblem
WarningC
"Bash requires ; or
\\
n here, after redirecting nested compound commands."
return
$
T_Redirecting
id
redirs
$
cmd
where
needsSeparator
=
choice
[
g_Then
,
g_Else
,
g_Elif
,
g_Fi
,
g_Do
,
g_Done
,
g_Esac
,
g_Rbrace
]
...
...
@@ -1499,7 +1513,11 @@ g_Rbrace = tryWordToken "}" T_Rbrace
g_Lparen
=
tryToken
"("
T_Lparen
g_Rparen
=
tryToken
")"
T_Rparen
g_Bang
=
tryToken
"!"
T_Bang
g_Bang
=
do
id
<-
getNextId
char
'!'
softCondSpacing
return
$
T_Bang
id
commonCommands
=
[
"admin"
,
"alias"
,
"ar"
,
"asa"
,
"at"
,
"awk"
,
"basename"
,
"batch"
,
"bc"
,
"bg"
,
"break"
,
"c99"
,
"cal"
,
"cat"
,
"cd"
,
"cflow"
,
"chgrp"
,
"chmod"
,
"chown"
,
"cksum"
,
"cmp"
,
"colon"
,
"comm"
,
"command"
,
"compress"
,
"continue"
,
"cp"
,
"crontab"
,
"csplit"
,
"ctags"
,
"cut"
,
"cxref"
,
"date"
,
"dd"
,
"delta"
,
"df"
,
"diff"
,
"dirname"
,
"dot"
,
"du"
,
"echo"
,
"ed"
,
"env"
,
"eval"
,
"ex"
,
"exec"
,
"exit"
,
"expand"
,
"export"
,
"expr"
,
"fc"
,
"fg"
,
"file"
,
"find"
,
"fold"
,
"fort77"
,
"fuser"
,
"gencat"
,
"get"
,
"getconf"
,
"getopts"
,
"grep"
,
"hash"
,
"head"
,
"iconv"
,
"ipcrm"
,
"ipcs"
,
"jobs"
,
"join"
,
"kill"
,
"lex"
,
"link"
,
"ln"
,
"locale"
,
"localedef"
,
"logger"
,
"logname"
,
"lp"
,
"ls"
,
"m4"
,
"mailx"
,
"make"
,
"man"
,
"mesg"
,
"mkdir"
,
"mkfifo"
,
"more"
,
"mv"
,
"newgrp"
,
"nice"
,
"nl"
,
"nm"
,
"nohup"
,
"od"
,
"paste"
,
"patch"
,
"pathchk"
,
"pax"
,
"pr"
,
"printf"
,
"prs"
,
"ps"
,
"pwd"
,
"qalter"
,
"qdel"
,
"qhold"
,
"qmove"
,
"qmsg"
,
"qrerun"
,
"qrls"
,
"qselect"
,
"qsig"
,
"qstat"
,
"qsub"
,
"read"
,
"readonly"
,
"renice"
,
"return"
,
"rm"
,
"rmdel"
,
"rmdir"
,
"sact"
,
"sccs"
,
"sed"
,
"set"
,
"sh"
,
"shift"
,
"sleep"
,
"sort"
,
"split"
,
"strings"
,
"strip"
,
"stty"
,
"tabs"
,
"tail"
,
"talk"
,
"tee"
,
"test"
,
"time"
,
"times"
,
"touch"
,
"tput"
,
"tr"
,
"trap"
,
"tsort"
,
"tty"
,
"type"
,
"ulimit"
,
"umask"
,
"unalias"
,
"uname"
,
"uncompress"
,
"unexpand"
,
"unget"
,
"uniq"
,
"unlink"
,
"unset"
,
"uucp"
,
"uudecode"
,
"uuencode"
,
"uustat"
,
"uux"
,
"val"
,
"vi"
,
"wait"
,
"wc"
,
"what"
,
"who"
,
"write"
,
"xargs"
,
"yacc"
,
"zcat"
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录