mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-08-08 21:53:29 +08:00
Emit resolved rather than apparent filename for 'source' (fixes #1579)
This commit is contained in:
@@ -2098,14 +2098,15 @@ readSource t@(T_Redirecting _ _ (T_SimpleCommand cmdId _ (cmd:file':rest'))) = d
|
|||||||
return t
|
return t
|
||||||
else do
|
else do
|
||||||
sys <- Mr.asks systemInterface
|
sys <- Mr.asks systemInterface
|
||||||
input <-
|
(input, resolvedFile) <-
|
||||||
if filename == "/dev/null" -- always allow /dev/null
|
if filename == "/dev/null" -- always allow /dev/null
|
||||||
then return (Right "")
|
then return (Right "", filename)
|
||||||
else do
|
else do
|
||||||
currentScript <- Mr.asks currentFilename
|
currentScript <- Mr.asks currentFilename
|
||||||
paths <- mapMaybe getSourcePath <$> getCurrentAnnotations True
|
paths <- mapMaybe getSourcePath <$> getCurrentAnnotations True
|
||||||
filename' <- system $ siFindSource sys currentScript paths filename
|
resolved <- system $ siFindSource sys currentScript paths filename
|
||||||
system $ siReadFile sys filename'
|
contents <- system $ siReadFile sys resolved
|
||||||
|
return (contents, resolved)
|
||||||
case input of
|
case input of
|
||||||
Left err -> do
|
Left err -> do
|
||||||
parseNoteAtId (getId file) InfoC 1091 $
|
parseNoteAtId (getId file) InfoC 1091 $
|
||||||
@@ -2116,7 +2117,7 @@ readSource t@(T_Redirecting _ _ (T_SimpleCommand cmdId _ (cmd:file':rest'))) = d
|
|||||||
id2 <- getNewIdFor cmdId
|
id2 <- getNewIdFor cmdId
|
||||||
|
|
||||||
let included = do
|
let included = do
|
||||||
src <- subRead filename script
|
src <- subRead resolvedFile script
|
||||||
return $ T_SourceCommand id1 t (T_Include id2 src)
|
return $ T_SourceCommand id1 t (T_Include id2 src)
|
||||||
|
|
||||||
let failed = do
|
let failed = do
|
||||||
|
Reference in New Issue
Block a user