Check unset flags under dash and POSIX sh
The only acceptable flags for the unset builtin under POSIX sh and dash are [-fv]. Bash though, accepts [-n] too. This commits makes shellcheck warn about this.
This commit is contained in:
parent
6dcf4b8e64
commit
31c5601c5e
|
@ -152,6 +152,8 @@ prop_checkBashisms69 = verifyNot checkBashisms "#!/bin/sh\numask -S"
|
||||||
prop_checkBashisms70 = verify checkBashisms "#!/bin/sh\ntrap -l"
|
prop_checkBashisms70 = verify checkBashisms "#!/bin/sh\ntrap -l"
|
||||||
prop_checkBashisms71 = verify checkBashisms "#!/bin/sh\ntype -a ls"
|
prop_checkBashisms71 = verify checkBashisms "#!/bin/sh\ntype -a ls"
|
||||||
prop_checkBashisms72 = verifyNot checkBashisms "#!/bin/sh\ntype ls"
|
prop_checkBashisms72 = verifyNot checkBashisms "#!/bin/sh\ntype ls"
|
||||||
|
prop_checkBashisms73 = verify checkBashisms "#!/bin/sh\nunset -n namevar"
|
||||||
|
prop_checkBashisms74 = verifyNot checkBashisms "#!/bin/sh\nunset -f namevar"
|
||||||
checkBashisms = ForShell [Sh, Dash] $ \t -> do
|
checkBashisms = ForShell [Sh, Dash] $ \t -> do
|
||||||
params <- ask
|
params <- ask
|
||||||
kludge params t
|
kludge params t
|
||||||
|
@ -306,7 +308,8 @@ checkBashisms = ForShell [Sh, Dash] $ \t -> do
|
||||||
("trap", Just []),
|
("trap", Just []),
|
||||||
("type", Just []),
|
("type", Just []),
|
||||||
("ulimit", if isDash then Nothing else Just ["f"]),
|
("ulimit", if isDash then Nothing else Just ["f"]),
|
||||||
("umask", Just ["S"])
|
("umask", Just ["S"]),
|
||||||
|
("unset", Just ["f", "v"])
|
||||||
]
|
]
|
||||||
bashism t@(T_SourceCommand id src _) =
|
bashism t@(T_SourceCommand id src _) =
|
||||||
let name = fromMaybe "" $ getCommandName src
|
let name = fromMaybe "" $ getCommandName src
|
||||||
|
|
Loading…
Reference in New Issue