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:
Cristian Adrián Ontivero 2019-01-23 06:35:08 +01:00
parent 6dcf4b8e64
commit 31c5601c5e
No known key found for this signature in database
GPG Key ID: 00B7629CAD43E113
1 changed files with 4 additions and 1 deletions

View File

@ -152,6 +152,8 @@ prop_checkBashisms69 = verifyNot checkBashisms "#!/bin/sh\numask -S"
prop_checkBashisms70 = verify checkBashisms "#!/bin/sh\ntrap -l"
prop_checkBashisms71 = verify checkBashisms "#!/bin/sh\ntype -a 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
params <- ask
kludge params t
@ -306,7 +308,8 @@ checkBashisms = ForShell [Sh, Dash] $ \t -> do
("trap", Just []),
("type", Just []),
("ulimit", if isDash then Nothing else Just ["f"]),
("umask", Just ["S"])
("umask", Just ["S"]),
("unset", Just ["f", "v"])
]
bashism t@(T_SourceCommand id src _) =
let name = fromMaybe "" $ getCommandName src