mirror of
https://github.com/koalaman/shellcheck
synced 2025-08-20 13:23:55 -07:00
Update with new Bash 5.3 printf formats
This commit is contained in:
parent
64b172e090
commit
6a758d5dc7
1 changed files with 8 additions and 5 deletions
|
@ -725,6 +725,9 @@ prop_checkGetPrintfFormats4 = getPrintfFormats "%d%%%(%s)T" == "dT"
|
||||||
prop_checkGetPrintfFormats5 = getPrintfFormats "%bPassed: %d, %bFailed: %d%b, Skipped: %d, %bErrored: %d%b\\n" == "bdbdbdbdb"
|
prop_checkGetPrintfFormats5 = getPrintfFormats "%bPassed: %d, %bFailed: %d%b, Skipped: %d, %bErrored: %d%b\\n" == "bdbdbdbdb"
|
||||||
prop_checkGetPrintfFormats6 = getPrintfFormats "%s%s" == "ss"
|
prop_checkGetPrintfFormats6 = getPrintfFormats "%s%s" == "ss"
|
||||||
prop_checkGetPrintfFormats7 = getPrintfFormats "%s\n%s" == "ss"
|
prop_checkGetPrintfFormats7 = getPrintfFormats "%s\n%s" == "ss"
|
||||||
|
prop_checkGetPrintfFormats8 = getPrintfFormats "%ld" == "d"
|
||||||
|
prop_checkGetPrintfFormats9 = getPrintfFormats "%lld" == "d"
|
||||||
|
prop_checkGetPrintfFormats10 = getPrintfFormats "%Q" == "Q"
|
||||||
getPrintfFormats = getFormats
|
getPrintfFormats = getFormats
|
||||||
where
|
where
|
||||||
-- Get the arguments in the string as a string of type characters,
|
-- Get the arguments in the string as a string of type characters,
|
||||||
|
@ -743,17 +746,17 @@ getPrintfFormats = getFormats
|
||||||
|
|
||||||
regexBasedGetFormats rest =
|
regexBasedGetFormats rest =
|
||||||
case matchRegex re rest of
|
case matchRegex re rest of
|
||||||
Just [width, precision, typ, rest, _] ->
|
Just [width, precision, len, typ, rest, _] ->
|
||||||
(if width == "*" then "*" else "") ++
|
(if width == "*" then "*" else "") ++
|
||||||
(if precision == "*" then "*" else "") ++
|
(if precision == "*" then "*" else "") ++
|
||||||
typ ++ getFormats rest
|
typ ++ getFormats rest
|
||||||
Nothing -> take 1 rest ++ getFormats rest
|
Nothing -> take 1 rest ++ getFormats rest
|
||||||
where
|
where
|
||||||
-- constructed based on specifications in "man printf"
|
-- constructed based on specifications in "man printf"
|
||||||
re = mkRegex "#?-?\\+? ?0?(\\*|\\d*)\\.?(\\d*|\\*)([diouxXfFeEgGaAcsbq])((\n|.)*)"
|
re = mkRegex "^#?-?\\+? ?0?(\\*|\\d*)\\.?(\\d*|\\*)(hh|h|l|ll|q|L|j|z|Z|t)?([diouxXfFeEgGaAcsbqQSC])((\n|.)*)"
|
||||||
-- \____ _____/\___ ____/ \____ ____/\_________ _________/ \______ /
|
-- \____ _____/\___ ____/ \____ ____/\__________ ___________/\___________ ___________/\___ ___/
|
||||||
-- V V V V V
|
-- V V V V V V
|
||||||
-- flags field width precision format character rest
|
-- flags field width precision length modifier format character rest
|
||||||
-- field width and precision can be specified with an '*' instead of a digit,
|
-- field width and precision can be specified with an '*' instead of a digit,
|
||||||
-- in which case printf will accept one more argument for each '*' used
|
-- in which case printf will accept one more argument for each '*' used
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue