Check hash flags under dash and POSIX sh

Flags for the hash builtin other than [-r] are undefined under POSIX sh.
Dash also accepts [-v], while bash adds [-l] [-p filename] [-dt] aside
from [-r].
This commit is contained in:
Cristian Adrián Ontivero 2019-01-27 08:22:37 +01:00
parent 420d913bbf
commit a669e1684b
No known key found for this signature in database
GPG Key ID: 00B7629CAD43E113
1 changed files with 4 additions and 0 deletions

View File

@ -158,6 +158,9 @@ prop_checkBashisms75 = verifyNot checkBashisms "#!/bin/sh\necho \"-n foo\""
prop_checkBashisms76 = verifyNot checkBashisms "#!/bin/sh\necho \"-ne foo\"" prop_checkBashisms76 = verifyNot checkBashisms "#!/bin/sh\necho \"-ne foo\""
prop_checkBashisms77 = verifyNot checkBashisms "#!/bin/sh\necho -Q foo" prop_checkBashisms77 = verifyNot checkBashisms "#!/bin/sh\necho -Q foo"
prop_checkBashisms78 = verify checkBashisms "#!/bin/sh\necho -ne foo" prop_checkBashisms78 = verify checkBashisms "#!/bin/sh\necho -ne foo"
prop_checkBashisms79 = verify checkBashisms "#!/bin/sh\nhash -l"
prop_checkBashisms80 = verifyNot checkBashisms "#!/bin/sh\nhash -r"
prop_checkBashisms81 = verifyNot checkBashisms "#!/bin/dash\nhash -v"
checkBashisms = ForShell [Sh, Dash] $ \t -> do checkBashisms = ForShell [Sh, Dash] $ \t -> do
params <- ask params <- ask
kludge params t kludge params t
@ -307,6 +310,7 @@ checkBashisms = ForShell [Sh, Dash] $ \t -> do
("cd", Just ["L", "P"]), ("cd", Just ["L", "P"]),
("exec", Just []), ("exec", Just []),
("export", Just ["p"]), ("export", Just ["p"]),
("hash", Just $ if isDash then ["r", "v"] else ["r"]),
("jobs", Just ["l", "p"]), ("jobs", Just ["l", "p"]),
("printf", Just []), ("printf", Just []),
("read", Just $ if isDash then ["r", "p"] else ["r"]), ("read", Just $ if isDash then ["r", "p"] else ["r"]),