mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-16 10:03:08 -07:00
Save and restore pending here docs when sourcing files (fixes #2803)
This commit is contained in:
parent
372c0b667e
commit
9490b94886
3 changed files with 19 additions and 3 deletions
|
@ -1,8 +1,9 @@
|
||||||
## Git
|
## Git
|
||||||
### Added
|
### Added
|
||||||
- SC2324: Warn when x+=1 appends instead of increments.
|
- SC2324: Warn when x+=1 appends instead of increments
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
- source statements with here docs now work correctly
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
|
@ -508,5 +508,14 @@ prop_rcCanSuppressEarlyProblems2 = null result
|
||||||
csScript = "!/bin/bash\necho 'hello world'"
|
csScript = "!/bin/bash\necho 'hello world'"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prop_sourceWithHereDocWorks = null result
|
||||||
|
where
|
||||||
|
result = checkWithIncludes [("bar", "true\n")] "source bar << eof\nlol\neof"
|
||||||
|
|
||||||
|
prop_hereDocsAreParsedWithoutTrailingLinefeed = 1044 `elem` result
|
||||||
|
where
|
||||||
|
result = check "cat << eof"
|
||||||
|
|
||||||
|
|
||||||
return []
|
return []
|
||||||
runTests = $quickCheckAll
|
runTests = $quickCheckAll
|
||||||
|
|
|
@ -2283,8 +2283,13 @@ readSource t@(T_Redirecting _ _ (T_SimpleCommand cmdId _ (cmd:file':rest'))) = d
|
||||||
|
|
||||||
subRead name script =
|
subRead name script =
|
||||||
withContext (ContextSource name) $
|
withContext (ContextSource name) $
|
||||||
inSeparateContext $
|
inSeparateContext $ do
|
||||||
subParse (initialPos name) (readScriptFile True) script
|
oldState <- getState
|
||||||
|
setState $ oldState { pendingHereDocs = [] }
|
||||||
|
result <- subParse (initialPos name) (readScriptFile True) script
|
||||||
|
newState <- getState
|
||||||
|
setState $ newState { pendingHereDocs = pendingHereDocs oldState }
|
||||||
|
return result
|
||||||
readSource t = return t
|
readSource t = return t
|
||||||
|
|
||||||
|
|
||||||
|
@ -3322,6 +3327,7 @@ readScriptFile sourced = do
|
||||||
then do
|
then do
|
||||||
commands <- readCompoundListOrEmpty
|
commands <- readCompoundListOrEmpty
|
||||||
id <- endSpan start
|
id <- endSpan start
|
||||||
|
readPendingHereDocs
|
||||||
verifyEof
|
verifyEof
|
||||||
let script = T_Annotation annotationId annotations $
|
let script = T_Annotation annotationId annotations $
|
||||||
T_Script id shebang commands
|
T_Script id shebang commands
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue