Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Annlix
ShellCheck
提交
1dbbc51f
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,发现更多精彩内容 >>
提交
1dbbc51f
编写于
5月 28, 2013
作者:
V
Vidar Holen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improved regex parsing. To think [[ f =~ f( ]] )* ]] is valid..
上级
6b89f33d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
33 addition
and
5 deletion
+33
-5
ShellCheck/Analytics.hs
ShellCheck/Analytics.hs
+5
-4
ShellCheck/Parser.hs
ShellCheck/Parser.hs
+28
-1
未找到文件。
ShellCheck/Analytics.hs
浏览文件 @
1dbbc51f
...
...
@@ -155,6 +155,7 @@ isGlob _ = False
isConfusedGlobRegex
(
'*'
:
_
)
=
True
isConfusedGlobRegex
[
x
,
'*'
]
|
x
/=
'
\\
'
=
True
isConfusedGlobRegex
_
=
False
isPotentiallyConfusedGlobRegex
=
...
...
@@ -588,10 +589,10 @@ prop_checkGlobbedRegex2a = verify checkGlobbedRegex "[[ $foo =~ \\#* ]]"
prop_checkGlobbedRegex3
=
verifyNot
checkGlobbedRegex
"[[ $foo =~ $foo ]]"
prop_checkGlobbedRegex4
=
verifyNot
checkGlobbedRegex
"[[ $foo =~ ^c.* ]]"
checkGlobbedRegex
(
TC_Binary
_
DoubleBracket
"=~"
_
rhs
)
=
case
rhs
of
T_NormalWord
id
((
T_Glob
_
"*"
)
:
_
)
->
warn
id
$
"=~ is for regex. Use == for globs."
T_NormalWord
id
([(
T_Literal
_
[
c
]),
(
T_Glob
_
"*"
)])
->
warn
id
$
"=~ is for regex. Either ^anchor$ this, or treat it as a glob with ==
."
_
->
return
()
let
s
=
concat
$
deadSimple
rhs
in
if
isConfusedGlobRegex
s
then
warn
(
getId
rhs
)
$
"=~ is for regex. Use == for globs
."
else
return
()
checkGlobbedRegex
_
=
return
()
...
...
ShellCheck/Parser.hs
浏览文件 @
1dbbc51f
...
...
@@ -291,8 +291,11 @@ readConditionContents single = do
)
(
do
pos
<-
getPosition
isRegex
<-
regexOperatorAhead
op
<-
readCondBinaryOp
y
<-
readCondWord
<|>
(
(
parseProblemAt
pos
ErrorC
$
"Expected another argument for this operator."
)
>>
mzero
)
y
<-
if
isRegex
then
readRegex
else
readCondWord
<|>
(
(
parseProblemAt
pos
ErrorC
$
"Expected another argument for this operator."
)
>>
mzero
)
return
(
x
`
op
`
y
)
)
<|>
(
return
$
TC_Noary
id
typ
x
)
...
...
@@ -316,6 +319,28 @@ readConditionContents single = do
isEscaped
_
=
False
xor
x
y
=
x
&&
not
y
||
not
x
&&
y
-- Currently a bit of a hack since parsing rules are obscure
regexOperatorAhead
=
(
lookAhead
$
do
try
(
string
"=~"
)
<|>
try
(
string
"~="
)
return
True
)
<|>
return
False
readRegex
=
called
"regex"
$
do
id
<-
getNextId
parts
<-
many1
(
readGroup
<|>
readSingleQuoted
<|>
readDoubleQuoted
<|>
readDollar
<|>
readNormalLiteral
"( "
<|>
readGlobLiteral
)
disregard
spacing
return
$
T_NormalWord
id
parts
where
readGlobLiteral
=
do
id
<-
getNextId
s
<-
many1
extglobStart
return
$
T_Literal
id
s
readGroup
=
do
-- Fixme: account for vars and quotes in groups
id
<-
getNextId
char
'('
s
<-
readGenericLiteral
(
char
')'
)
char
')'
return
$
T_Literal
id
$
"("
++
s
++
")"
readCondTerm
=
readCondNot
<|>
readCondExpr
readCondNot
=
do
id
<-
getNextId
...
...
@@ -505,6 +530,8 @@ readArithmeticContents =
prop_readCondition
=
isOk
readCondition
"[
\\
( a = b
\\
) -a
\\
( c = d
\\
) ]"
prop_readCondition2
=
isOk
readCondition
"[[ (a = b) || (c = d) ]]"
prop_readCondition3
=
isOk
readCondition
"[[ $c = [[:alpha:].~-] ]]"
prop_readCondition4
=
isOk
readCondition
"[[ $c =~ *foo* ]]"
prop_readCondition5
=
isOk
readCondition
"[[ $c =~ f( ]] )* ]]"
readCondition
=
called
"test expression"
$
do
opos
<-
getPosition
id
<-
getNextId
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录