Skip to content

Commit cb4a0c0

Browse files
committed
Check if builtin cd is called
Fixes #1234
1 parent 467dfe0 commit cb4a0c0

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

src/ShellCheck/ASTLib.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ getCommand t =
261261
getCommandName t = do
262262
(T_SimpleCommand _ _ (w:rest)) <- getCommand t
263263
s <- getLiteralString w
264-
if "busybox" `isSuffixOf` s
264+
if "busybox" `isSuffixOf` s || "builtin" == s
265265
then
266266
case rest of
267267
(applet:_) -> getLiteralString applet

src/ShellCheck/Analytics.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2483,6 +2483,7 @@ prop_checkUncheckedCd5 = verifyTree checkUncheckedCdPushdPopd "if true; then cd
24832483
prop_checkUncheckedCd6 = verifyNotTree checkUncheckedCdPushdPopd "cd .."
24842484
prop_checkUncheckedCd7 = verifyNotTree checkUncheckedCdPushdPopd "#!/bin/bash -e\ncd foo\nrm bar"
24852485
prop_checkUncheckedCd8 = verifyNotTree checkUncheckedCdPushdPopd "set -o errexit; cd foo; rm bar"
2486+
prop_checkUncheckedCd9 = verifyTree checkUncheckedCdPushdPopd "builtin cd ~/src; rm -r foo"
24862487
prop_checkUncheckedPushd1 = verifyTree checkUncheckedCdPushdPopd "pushd ~/src; rm -r foo"
24872488
prop_checkUncheckedPushd2 = verifyNotTree checkUncheckedCdPushdPopd "pushd ~/src || exit; rm -r foo"
24882489
prop_checkUncheckedPushd3 = verifyNotTree checkUncheckedCdPushdPopd "set -e; pushd ~/src; rm -r foo"

0 commit comments

Comments
 (0)