Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Annlix
ShellCheck
提交
25ee7e20
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,发现更多精彩内容 >>
提交
25ee7e20
编写于
6月 25, 2013
作者:
V
Vidar Holen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added awkward check for PS1 escapes outside \[..\]
上级
438c4ec5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
34 addition
and
5 deletion
+34
-5
ShellCheck/Analytics.hs
ShellCheck/Analytics.hs
+34
-5
未找到文件。
ShellCheck/Analytics.hs
浏览文件 @
25ee7e20
...
@@ -118,6 +118,7 @@ basicChecks = [
...
@@ -118,6 +118,7 @@ basicChecks = [
,
checkTestRedirects
,
checkTestRedirects
,
checkIndirectExpansion
,
checkIndirectExpansion
,
checkSudoRedirect
,
checkSudoRedirect
,
checkPS1Assignments
]
]
treeChecks
=
[
treeChecks
=
[
checkUnquotedExpansions
checkUnquotedExpansions
...
@@ -197,6 +198,7 @@ deadSimple (T_Pipeline _ [x]) = deadSimple x
...
@@ -197,6 +198,7 @@ deadSimple (T_Pipeline _ [x]) = deadSimple x
deadSimple
(
T_Literal
_
x
)
=
[
x
]
deadSimple
(
T_Literal
_
x
)
=
[
x
]
deadSimple
(
T_SimpleCommand
_
vars
words
)
=
concatMap
(
deadSimple
)
words
deadSimple
(
T_SimpleCommand
_
vars
words
)
=
concatMap
(
deadSimple
)
words
deadSimple
(
T_Redirecting
_
_
foo
)
=
deadSimple
foo
deadSimple
(
T_Redirecting
_
_
foo
)
=
deadSimple
foo
deadSimple
(
T_DollarSingleQuoted
_
s
)
=
[
s
]
deadSimple
_
=
[]
deadSimple
_
=
[]
verify
f
s
=
checkBasic
f
s
==
Just
True
verify
f
s
=
checkBasic
f
s
==
Just
True
...
@@ -594,7 +596,7 @@ prop_checkGlobbedRegex3 = verifyNot checkGlobbedRegex "[[ $foo =~ $foo ]]"
...
@@ -594,7 +596,7 @@ prop_checkGlobbedRegex3 = verifyNot checkGlobbedRegex "[[ $foo =~ $foo ]]"
prop_checkGlobbedRegex4
=
verifyNot
checkGlobbedRegex
"[[ $foo =~ ^c.* ]]"
prop_checkGlobbedRegex4
=
verifyNot
checkGlobbedRegex
"[[ $foo =~ ^c.* ]]"
checkGlobbedRegex
(
TC_Binary
_
DoubleBracket
"=~"
_
rhs
)
=
checkGlobbedRegex
(
TC_Binary
_
DoubleBracket
"=~"
_
rhs
)
=
let
s
=
concat
$
deadSimple
rhs
in
let
s
=
concat
$
deadSimple
rhs
in
if
isConfusedGlobRegex
s
if
isConfusedGlobRegex
s
then
warn
(
getId
rhs
)
$
"=~ is for regex. Use == for globs."
then
warn
(
getId
rhs
)
$
"=~ is for regex. Use == for globs."
else
return
()
else
return
()
checkGlobbedRegex
_
=
return
()
checkGlobbedRegex
_
=
return
()
...
@@ -944,10 +946,10 @@ prop_checkSudoRedirect6 = verifyNot checkSudoRedirect "sudo cmd 2> log"
...
@@ -944,10 +946,10 @@ prop_checkSudoRedirect6 = verifyNot checkSudoRedirect "sudo cmd 2> log"
checkSudoRedirect
(
T_Redirecting
_
redirs
cmd
)
|
cmd
`
isCommand
`
"sudo"
=
checkSudoRedirect
(
T_Redirecting
_
redirs
cmd
)
|
cmd
`
isCommand
`
"sudo"
=
mapM_
warnAbout
redirs
mapM_
warnAbout
redirs
where
where
warnAbout
(
T_FdRedirect
_
s
(
T_IoFile
id
op
file
))
warnAbout
(
T_FdRedirect
_
s
(
T_IoFile
id
op
file
))
|
s
==
""
||
s
==
"&"
=
|
s
==
""
||
s
==
"&"
=
case
op
of
case
op
of
T_Less
_
->
T_Less
_
->
info
(
getId
op
)
$
info
(
getId
op
)
$
"sudo doesn't affect redirects. Use sudo cat file | .."
"sudo doesn't affect redirects. Use sudo cat file | .."
T_Greater
_
->
T_Greater
_
->
...
@@ -960,6 +962,33 @@ checkSudoRedirect (T_Redirecting _ redirs cmd) | cmd `isCommand` "sudo" =
...
@@ -960,6 +962,33 @@ checkSudoRedirect (T_Redirecting _ redirs cmd) | cmd `isCommand` "sudo" =
warnAbout
_
=
return
()
warnAbout
_
=
return
()
checkSudoRedirect
_
=
return
()
checkSudoRedirect
_
=
return
()
prop_checkPS11
=
verify
checkPS1Assignments
"PS1='
\\
033[1;35m
\\
$ '"
prop_checkPS11a
=
verify
checkPS1Assignments
"export PS1='
\\
033[1;35m
\\
$ '"
prop_checkPSf2
=
verify
checkPS1Assignments
"PS1='
\\
h
\\
e[0m
\\
$ '"
prop_checkPS13
=
verify
checkPS1Assignments
"PS1=$'
\\
x1b[c '"
prop_checkPS14
=
verify
checkPS1Assignments
"PS1=$'
\\
e[3m; '"
prop_checkPS14a
=
verify
checkPS1Assignments
"export PS1=$'
\\
e[3m; '"
prop_checkPS15
=
verifyNot
checkPS1Assignments
"PS1='
\\
[
\\
033[1;35m
\\
]
\\
$ '"
prop_checkPS16
=
verifyNot
checkPS1Assignments
"PS1='
\\
[
\\
e1m
\\
e[1m
\\
]
\\
$ '"
checkPS1Assignments
t
=
case
t
of
(
T_Assignment
_
"PS1"
word
)
->
warnFor
[
word
]
(
T_SimpleCommand
id
_
tokens
)
->
when
(
t
`
isCommand
`
"export"
)
$
warnFor
(
filter
isPS1Token
tokens
)
_
->
return
()
where
isPS1Token
t
=
"PS1"
`
isPrefixOf
`
(
concat
$
deadSimple
t
)
warnFor
words
=
let
contents
=
concat
$
concatMap
deadSimple
words
in
when
(
not
(
null
words
)
&&
containsUnescaped
contents
)
$
info
(
getId
$
head
words
)
"Make sure all escape sequences are enclosed in
\\
[..
\\
] to prevent line wrapping issues"
containsUnescaped
s
=
let
unenclosed
=
subRegex
enclosedRegex
s
""
in
isJust
$
matchRegex
escapeRegex
unenclosed
enclosedRegex
=
mkRegex
"
\\\\\\
[.*
\\\\\\
]"
-- FIXME: shouldn't be eager
escapeRegex
=
mkRegex
"
\\
x1[Bb]|
\\
e|
\x1B
|
\\
033"
prop_checkIndirectExpansion1
=
verify
checkIndirectExpansion
"${foo$n}"
prop_checkIndirectExpansion1
=
verify
checkIndirectExpansion
"${foo$n}"
prop_checkIndirectExpansion2
=
verifyNot
checkIndirectExpansion
"${foo//$n/lol}"
prop_checkIndirectExpansion2
=
verifyNot
checkIndirectExpansion
"${foo//$n/lol}"
checkIndirectExpansion
(
T_DollarBraced
id
(
T_NormalWord
_
((
T_Literal
_
s
)
:
attempt
:
_
)))
=
checkIndirectExpansion
(
T_DollarBraced
id
(
T_NormalWord
_
((
T_Literal
_
s
)
:
attempt
:
_
)))
=
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录