14 Commits

Author SHA1 Message Date
Vidar Holen
1553dba6af Merge pull request #3307 from e-kwsm/posix.1-2024
feat!: update commands in conformance with POSIX.1-2024
2025-09-24 19:18:53 -07:00
Vidar Holen
aa07ba0d2a Merge pull request #3311 from e-kwsm/gitignore
chore: update .gitignore [skip ci]
2025-09-24 19:18:31 -07:00
Vidar Holen
6a876f0b48 Merge pull request #3309 from e-kwsm/timeout
feat(SC2033): check timeout (POSIX.1-2024)
2025-09-24 19:18:08 -07:00
Vidar Holen
8c616761fa Merge pull request #3305 from e-kwsm/pipefail
feat(SC3040): support `set -o pipefail` as specified by POSIX.1-2024
2025-09-24 19:16:19 -07:00
Vidar Holen
94ded2db74 Merge pull request #3304 from e-kwsm/ulimit
feat(SC3045): update ulimit options in conformance with POSIX.1-2024
2025-09-24 19:15:38 -07:00
Vidar Holen
a0716497fb Merge pull request #3303 from e-kwsm/ISSUE_TEMPLATE
chore: remove obsolescent ISSUE_TEMPLATE
2025-09-24 19:14:13 -07:00
Vidar Holen
b23c013549 Merge pull request #3297 from dereckson/duplicate-bash-vars
Remove duplicate from SC3028 bash variables list
2025-09-24 19:12:55 -07:00
Eisuke Kawashima
32cae7a1c5 feat(SC2033): check timeout (POSIX.1-2024)
fix #3308
2025-09-20 10:21:40 +09:00
Eisuke Kawashima
5de0448a72 feat!: update commands in conformance with POSIX.1-2024
added:
- gettext
- msgfmt
- ngettext
- readlink
- realpath
- timeout
- xgettext

removed:
- fort77
- qalter
- qdel
- qhold
- qmove
- qmsg
- qrerun
- qrls
- qselect
- qsig
- qstat
- qsub

https://pubs.opengroup.org/onlinepubs/9799919799/xrat/V4_xcu_chap01.html
2025-09-20 09:44:15 +09:00
Eisuke Kawashima
6d4fa9fb2c feat(SC3040): support set -o pipefail as specified by POSIX.1-2024
fix #2555
2025-09-19 18:39:35 +09:00
Eisuke Kawashima
14aac627f4 feat(SC3045): update ulimit options in conformance with POSIX.1-2024
n.b. dash supports `ulimit -r` since v0.5.12-10-g4bdefd16c6ea

fix #3289

https://pubs.opengroup.org/onlinepubs/9799919799/utilities/ulimit.html
2025-09-19 17:35:45 +09:00
Eisuke Kawashima
aea67a4532 chore: remove obsolescent ISSUE_TEMPLATE 2025-09-19 17:31:08 +09:00
Sébastien Santoro
da12ce67f5 Remove duplicate from SC3028 bash variables list 2025-09-15 22:09:33 +00:00
Eisuke Kawashima
fce4bc8352 chore: update .gitignore [skip ci] 2025-08-05 23:28:55 +09:00
6 changed files with 37 additions and 52 deletions

View File

@@ -1,27 +0,0 @@
#### For bugs
- Rule Id (if any, e.g. SC1000):
- My shellcheck version (`shellcheck --version` or "online"):
- [ ] The rule's wiki page does not already cover this (e.g. https://shellcheck.net/wiki/SC2086)
- [ ] I tried on https://www.shellcheck.net/ and verified that this is still a problem on the latest commit
#### For new checks and feature suggestions
- [ ] https://www.shellcheck.net/ (i.e. the latest commit) currently gives no useful warnings about this
- [ ] I searched through https://github.com/koalaman/shellcheck/issues and didn't find anything related
#### Here's a snippet or screenshot that shows the problem:
```sh
#!/your/interpreter
your script here
```
#### Here's what shellcheck currently says:
#### Here's what I wanted or expected to see:

4
.gitignore vendored
View File

@@ -14,6 +14,7 @@ cabal.sandbox.config
cabal.config
cabal.project.freeze
.stack-work
stack.yaml.lock
### Snap ###
/snap/.snapcraft/
@@ -22,3 +23,6 @@ cabal.project.freeze
/prime/
*.snap
/dist-newstyle/
### misc ###
/shellcheck.1

View File

@@ -2349,6 +2349,8 @@ prop_checkFunctionsUsedExternally8 =
verifyTree checkFunctionsUsedExternally "foo() { :; }; command sudo foo"
prop_checkFunctionsUsedExternally9 =
verifyTree checkFunctionsUsedExternally "foo() { :; }; exec -c doas foo"
prop_checkFunctionsUsedExternally10 =
verifyTree checkFunctionsUsedExternally "foo() { :; }; timeout -p 10 foo"
checkFunctionsUsedExternally params t =
runNodeAnalysis checkCommand params t
where
@@ -2376,6 +2378,7 @@ checkFunctionsUsedExternally params t =
"run0" -> firstNonFlag
"xargs" -> firstNonFlag
"tmux" -> firstNonFlag
"timeout" -> take 1 $ drop 1 $ dropFlags argAndString
"ssh" -> take 1 $ drop 1 $ dropFlags argAndString
"find" -> take 1 $ drop 1 $
dropWhile (\x -> fst x `notElem` findExecFlags) argAndString

View File

@@ -224,9 +224,9 @@ makeParameters spec = params
hasPipefail =
case shellType params of
Bash -> isOptionSet "pipefail" root
Dash -> True
Dash -> isOptionSet "pipefail" root
BusyboxSh -> isOptionSet "pipefail" root
Sh -> True
Sh -> isOptionSet "pipefail" root
Ksh -> isOptionSet "pipefail" root,
hasExecfail =
case shellType params of

View File

@@ -148,8 +148,8 @@ prop_checkBashisms53 = verifyNot checkBashisms "#!/bin/sh\nprintf -- -f\n"
prop_checkBashisms54 = verify checkBashisms "#!/bin/sh\nfoo+=bar"
prop_checkBashisms55 = verify checkBashisms "#!/bin/sh\necho ${@%foo}"
prop_checkBashisms56 = verifyNot checkBashisms "#!/bin/sh\necho ${##}"
prop_checkBashisms57 = verifyNot checkBashisms "#!/bin/dash\nulimit -c 0"
prop_checkBashisms58 = verify checkBashisms "#!/bin/sh\nulimit -c 0"
prop_checkBashisms57 = verifyNot checkBashisms "#!/bin/dash\nulimit -m unlimited"
prop_checkBashisms58 = verify checkBashisms "#!/bin/sh\nulimit -x unlimited"
prop_checkBashisms59 = verify checkBashisms "#!/bin/sh\njobs -s"
prop_checkBashisms60 = verifyNot checkBashisms "#!/bin/sh\njobs -p"
prop_checkBashisms61 = verifyNot checkBashisms "#!/bin/sh\njobs -lp"
@@ -175,7 +175,7 @@ prop_checkBashisms80 = verifyNot checkBashisms "#!/bin/sh\nhash -r"
prop_checkBashisms81 = verifyNot checkBashisms "#!/bin/dash\nhash -v"
prop_checkBashisms82 = verifyNot checkBashisms "#!/bin/sh\nset -v +o allexport -o errexit -C"
prop_checkBashisms83 = verifyNot checkBashisms "#!/bin/sh\nset --"
prop_checkBashisms84 = verify checkBashisms "#!/bin/sh\nset -o pipefail"
prop_checkBashisms84 = verifyNot checkBashisms "#!/bin/sh\nset -o pipefail"
prop_checkBashisms85 = verify checkBashisms "#!/bin/sh\nset -B"
prop_checkBashisms86 = verifyNot checkBashisms "#!/bin/dash\nset -o emacs"
prop_checkBashisms87 = verify checkBashisms "#!/bin/sh\nset -o emacs"
@@ -383,8 +383,8 @@ checkBashisms = ForShell [Sh, Dash, BusyboxSh] $ \t -> do
beginsWithDoubleDash = (`matches` mkRegex "^--.+$")
longOptions = Set.fromList
[ "allexport", "errexit", "ignoreeof", "monitor", "noclobber"
, "noexec", "noglob", "nolog", "notify" , "nounset", "verbose"
, "vi", "xtrace" ]
, "noexec", "noglob", "nolog", "notify" , "nounset", "pipefail"
, "verbose", "vi", "xtrace" ]
bashism t@(T_SimpleCommand id _ (cmd:rest)) =
let name = fromMaybe "" $ getCommandName t
@@ -446,7 +446,12 @@ checkBashisms = ForShell [Sh, Dash, BusyboxSh] $ \t -> do
("readonly", Just ["p"]),
("trap", Just []),
("type", Just $ if isBusyboxSh then ["p"] else []),
("ulimit", if isDash then Nothing else Just ["f"]),
("ulimit",
Just $
if isDash
then ["H", "S", "a", "c", "d", "f", "l", "m", "n", "p", "r", "s", "t", "v", "w"]
else ["H", "S", "a", "c", "d", "f", "n", "s", "t", "v"] -- POSIX.1-2024
),
("umask", Just ["S"]),
("unset", Just ["f", "v"]),
("wait", Just [])
@@ -483,7 +488,7 @@ checkBashisms = ForShell [Sh, Dash, BusyboxSh] $ \t -> do
"BASH_ARGV", "BASH_ARGV0", "BASH_CMDS", "BASH_COMMAND",
"BASH_EXECUTION_STRING", "BASH_LINENO", "BASH_REMATCH", "BASH_SOURCE",
"BASH_SUBSHELL", "BASH_VERSINFO", "EPOCHREALTIME", "EPOCHSECONDS",
"FUNCNAME", "GROUPS", "MACHTYPE", "MAPFILE"
"FUNCNAME", "GROUPS", "MAPFILE"
]
bashDynamicVars = [ "RANDOM", "SECONDS" ]
dashVars = [ "_" ]

View File

@@ -104,31 +104,31 @@ commonCommands = [
"compress", "continue", "cp", "crontab", "csplit", "ctags", "cut",
"cxref", "date", "dd", "delta", "df", "diff", "dirname", "dot",
"du", "echo", "ed", "env", "eval", "ex", "exec", "exit", "expand",
"export", "expr", "fc", "fg", "file", "find", "fold", "fort77",
"fuser", "gencat", "get", "getconf", "getopts", "grep", "hash",
"export", "expr", "fc", "fg", "file", "find", "fold", "fuser",
"gencat", "get", "getconf", "getopts", "gettext", "grep", "hash",
"head", "iconv", "ipcrm", "ipcs", "jobs", "join", "kill", "lex",
"link", "ln", "locale", "localedef", "logger", "logname", "lp",
"ls", "m4", "mailx", "make", "man", "mesg", "mkdir", "mkfifo",
"more", "mv", "newgrp", "nice", "nl", "nm", "nohup", "od", "paste",
"patch", "pathchk", "pax", "pr", "printf", "prs", "ps", "pwd",
"qalter", "qdel", "qhold", "qmove", "qmsg", "qrerun", "qrls",
"qselect", "qsig", "qstat", "qsub", "read", "readonly", "renice",
"return", "rm", "rmdel", "rmdir", "sact", "sccs", "sed", "set",
"sh", "shift", "sleep", "sort", "split", "strings", "strip", "stty",
"tabs", "tail", "talk", "tee", "test", "time", "times", "touch",
"tput", "tr", "trap", "tsort", "tty", "type", "ulimit", "umask",
"unalias", "uname", "uncompress", "unexpand", "unget", "uniq",
"unlink", "unset", "uucp", "uudecode", "uuencode", "uustat", "uux",
"val", "vi", "wait", "wc", "what", "who", "write", "xargs", "yacc",
"zcat"
"more", "msgfmt", "mv", "newgrp", "ngettext", "nice", "nl", "nm",
"nohup", "od", "paste", "patch", "pathchk", "pax", "pr", "printf",
"prs", "ps", "pwd", "read", "readlink", "readonly", "realpath",
"renice", "return", "rm", "rmdel", "rmdir", "sact", "sccs", "sed",
"set", "sh", "shift", "sleep", "sort", "split", "strings", "strip",
"stty", "tabs", "tail", "talk", "tee", "test", "time", "timeout",
"times", "touch", "tput", "tr", "trap", "tsort", "tty", "type",
"ulimit", "umask", "unalias", "uname", "uncompress", "unexpand",
"unget", "uniq", "unlink", "unset", "uucp", "uudecode", "uuencode",
"uustat", "uux", "val", "vi", "wait", "wc", "what", "who", "write",
"xargs", "xgettext", "yacc", "zcat"
]
nonReadingCommands = [
"alias", "basename", "bg", "cal", "cd", "chgrp", "chmod", "chown",
"cp", "du", "echo", "export", "fg", "fuser", "getconf",
"getopt", "getopts", "ipcrm", "ipcs", "jobs", "kill", "ln", "ls",
"locale", "mv", "printf", "ps", "pwd", "renice", "rm", "rmdir",
"set", "sleep", "touch", "trap", "ulimit", "unalias", "uname"
"locale", "mv", "printf", "ps", "pwd", "readlink", "realpath",
"renice", "rm", "rmdir", "set", "sleep", "touch", "trap", "ulimit",
"unalias", "uname"
]
sampleWords = [