Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Annlix
ShellCheck
提交
619b6c42
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,发现更多精彩内容 >>
提交
619b6c42
编写于
10月 21, 2016
作者:
V
Vidar Holen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve parsing of fd close/duplicate redirections.
上级
88c56ecd
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
28 addition
and
22 deletion
+28
-22
ShellCheck/AST.hs
ShellCheck/AST.hs
+3
-0
ShellCheck/Analytics.hs
ShellCheck/Analytics.hs
+2
-1
ShellCheck/Parser.hs
ShellCheck/Parser.hs
+23
-21
未找到文件。
ShellCheck/AST.hs
浏览文件 @
619b6c42
...
...
@@ -99,6 +99,7 @@ data Token =
|
T_IfExpression
Id
[([
Token
],[
Token
])]
[
Token
]
|
T_In
Id
|
T_IoFile
Id
Token
Token
|
T_IoDuplicate
Id
Token
String
|
T_LESSAND
Id
|
T_LESSGREAT
Id
|
T_Lbrace
Id
...
...
@@ -189,6 +190,7 @@ analyze f g i =
delve
(
T_DollarArithmetic
id
c
)
=
d1
c
$
T_DollarArithmetic
id
delve
(
T_DollarBracket
id
c
)
=
d1
c
$
T_DollarBracket
id
delve
(
T_IoFile
id
op
file
)
=
d2
op
file
$
T_IoFile
id
delve
(
T_IoDuplicate
id
op
num
)
=
d1
op
$
\
x
->
T_IoDuplicate
id
x
num
delve
(
T_HereString
id
word
)
=
d1
word
$
T_HereString
id
delve
(
T_FdRedirect
id
v
t
)
=
d1
t
$
T_FdRedirect
id
v
delve
(
T_Assignment
id
mode
var
indices
value
)
=
do
...
...
@@ -318,6 +320,7 @@ getId t = case t of
T_BraceExpansion
id
_
->
id
T_DollarBraceCommandExpansion
id
_
->
id
T_IoFile
id
_
_
->
id
T_IoDuplicate
id
_
_
->
id
T_HereDoc
id
_
_
_
_
->
id
T_HereString
id
_
->
id
T_FdRedirect
id
_
_
->
id
...
...
ShellCheck/Analytics.hs
浏览文件 @
619b6c42
...
...
@@ -509,6 +509,7 @@ prop_checkBashisms48= verifyNot checkBashisms "#!/bin/dash\necho $LINENO"
prop_checkBashisms49
=
verify
checkBashisms
"#!/bin/dash
\n
echo $MACHTYPE"
prop_checkBashisms50
=
verify
checkBashisms
"#!/bin/sh
\n
cmd >& file"
prop_checkBashisms51
=
verifyNot
checkBashisms
"#!/bin/sh
\n
cmd 2>&1"
prop_checkBashisms52
=
verifyNot
checkBashisms
"#!/bin/sh
\n
cmd >&2"
checkBashisms
params
=
bashism
where
isDash
=
shellType
params
==
Dash
...
...
@@ -983,7 +984,7 @@ prop_checkStderrRedirect4 = verifyNot checkStderrRedirect "errors=$(test 2>&1 >
prop_checkStderrRedirect5
=
verifyNot
checkStderrRedirect
"read < <(test 2>&1 > file)"
prop_checkStderrRedirect6
=
verify
checkStderrRedirect
"foo | bar 2>&1 > /dev/null"
checkStderrRedirect
params
redir
@
(
T_Redirecting
_
[
T_FdRedirect
id
"2"
(
T_Io
File
_
(
T_GREATAND
_
)
(
T_NormalWord
_
[
T_Literal
_
"1"
])
),
T_FdRedirect
id
"2"
(
T_Io
Duplicate
_
(
T_GREATAND
_
)
"1"
),
T_FdRedirect
_
_
(
T_IoFile
_
op
_
)
]
_
)
=
case
op
of
T_Greater
_
->
error
...
...
ShellCheck/Parser.hs
浏览文件 @
619b6c42
...
...
@@ -1547,7 +1547,7 @@ readHereDoc = called "here document" $ do
-- add empty tokens for now, read the rest in readPendingHereDocs
let
doc
=
T_HereDoc
hid
dashed
quoted
endToken
[]
addPendingHereDoc
doc
return
$
T_FdRedirect
fid
""
doc
return
doc
where
stripLiteral
(
T_Literal
_
x
)
=
x
stripLiteral
(
T_SingleQuoted
_
x
)
=
x
...
...
@@ -1618,7 +1618,13 @@ readPendingHereDocs = do
readFilename
=
readNormalWord
readIoFileOp
=
choice
[
g_LESSAND
,
g_GREATAND
,
g_DGREAT
,
g_LESSGREAT
,
g_CLOBBER
,
redirToken
'<'
T_Less
,
redirToken
'>'
T_Greater
]
readIoFileOp
=
choice
[
g_DGREAT
,
g_LESSGREAT
,
g_GREATAND
,
g_LESSAND
,
g_CLOBBER
,
redirToken
'<'
T_Less
,
redirToken
'>'
T_Greater
]
readIoDuplicate
=
try
$
do
id
<-
getNextId
op
<-
g_GREATAND
<|>
g_LESSAND
target
<-
readIoVariable
<|>
many1
digit
<|>
string
"-"
return
$
T_IoDuplicate
id
op
target
prop_readIoFile
=
isOk
readIoFile
">>
\"
$(date +%YYmmDD)
\"
"
readIoFile
=
called
"redirection"
$
do
...
...
@@ -1626,35 +1632,31 @@ readIoFile = called "redirection" $ do
op
<-
readIoFileOp
spacing
file
<-
readFilename
return
$
T_
FdRedirect
id
""
$
T_
IoFile
id
op
file
return
$
T_IoFile
id
op
file
readIoVariable
=
try
$
do
char
'{'
x
<-
readVariableName
char
'}'
lookAhead
readIoFileOp
return
$
"{"
++
x
++
"}"
readIo
Number
=
try
$
do
x
<-
many1
digit
<|>
string
"&"
lookAhead
readIoFileOp
readIo
Source
=
try
$
do
x
<-
string
"&"
<|>
readIoVariable
<|>
many
digit
lookAhead
$
void
readIoFileOp
<|>
void
(
string
"<<"
)
return
x
prop_readIo
NumberRedirect
=
isOk
readIoNumber
Redirect
"3>&2"
prop_readIo
NumberRedirect2
=
isOk
readIoNumber
Redirect
"2> lol"
prop_readIo
NumberRedirect3
=
isOk
readIoNumber
Redirect
"4>&-"
prop_readIo
NumberRedirect4
=
isOk
readIoNumber
Redirect
"&> lol"
prop_readIo
NumberRedirect5
=
isOk
readIoNumber
Redirect
"{foo}>&2"
prop_readIo
NumberRedirect6
=
isOk
readIoNumber
Redirect
"{foo}<&-"
readIo
Number
Redirect
=
do
prop_readIo
Redirect
=
isOk
readIo
Redirect
"3>&2"
prop_readIo
Redirect2
=
isOk
readIo
Redirect
"2> lol"
prop_readIo
Redirect3
=
isOk
readIo
Redirect
"4>&-"
prop_readIo
Redirect4
=
isOk
readIo
Redirect
"&> lol"
prop_readIo
Redirect5
=
isOk
readIo
Redirect
"{foo}>&2"
prop_readIo
Redirect6
=
isOk
readIo
Redirect
"{foo}<&-"
readIoRedirect
=
do
id
<-
getNextId
n
<-
readIoVariable
<|>
readIoNumber
op
<-
readHereString
<|>
readHereDoc
<|>
readIoFile
let
actualOp
=
case
op
of
T_FdRedirect
_
""
x
->
x
n
<-
readIoSource
redir
<-
readHereString
<|>
readHereDoc
<|>
readIoDuplicate
<|>
readIoFile
spacing
return
$
T_FdRedirect
id
n
actualOp
readIoRedirect
=
choice
[
readIoNumberRedirect
,
readHereString
,
readHereDoc
,
readIoFile
]
`
thenSkip
`
spacing
return
$
T_FdRedirect
id
n
redir
readRedirectList
=
many1
readIoRedirect
...
...
@@ -1665,7 +1667,7 @@ readHereString = called "here string" $ do
spacing
id2
<-
getNextId
word
<-
readNormalWord
return
$
T_
FdRedirect
id
""
$
T_
HereString
id2
word
return
$
T_HereString
id2
word
readNewlineList
=
many1
((
linefeed
<|>
carriageReturn
)
`
thenSkip
`
spacing
)
readLineBreak
=
optional
readNewlineList
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录