mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-08-25 21:16:52 +08:00
Normalize \ to / in diff output on Windows (fixes #3240)
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
re-enabled with `--enable=useless-use-of-cat` or equivalent directive.
|
re-enabled with `--enable=useless-use-of-cat` or equivalent directive.
|
||||||
- SC2015 about `A && B || C` no longer triggers when B is a test command.
|
- SC2015 about `A && B || C` no longer triggers when B is a test command.
|
||||||
- SC3012: Do not warn about `\<` and `\>` in test/[] as specified in POSIX.1-2024
|
- SC3012: Do not warn about `\<` and `\>` in test/[] as specified in POSIX.1-2024
|
||||||
|
- Diff output now uses / as path separator on Windows
|
||||||
### Fixed
|
### Fixed
|
||||||
- SC2218 about function use-before-define is now more accurate.
|
- SC2218 about function use-before-define is now more accurate.
|
||||||
- SC2317 about unreachable commands is now less spammy for nested ones.
|
- SC2317 about unreachable commands is now less spammy for nested ones.
|
||||||
|
@@ -191,11 +191,17 @@ splitLast x =
|
|||||||
let (last, rest) = splitAt 1 $ reverse x
|
let (last, rest) = splitAt 1 $ reverse x
|
||||||
in (reverse rest, last)
|
in (reverse rest, last)
|
||||||
|
|
||||||
|
-- git patch does not like `\` on Windows
|
||||||
|
normalizePath path =
|
||||||
|
case path of
|
||||||
|
c:rest -> (if c == pathSeparator then '/' else c) : normalizePath rest
|
||||||
|
[] -> []
|
||||||
|
|
||||||
formatDoc color (DiffDoc name lf regions) =
|
formatDoc color (DiffDoc name lf regions) =
|
||||||
let (most, last) = splitLast regions
|
let (most, last) = splitLast regions
|
||||||
in
|
in
|
||||||
(color bold $ "--- " ++ ("a" </> name)) ++ "\n" ++
|
(color bold $ "--- " ++ (normalizePath $ "a" </> name)) ++ "\n" ++
|
||||||
(color bold $ "+++ " ++ ("b" </> name)) ++ "\n" ++
|
(color bold $ "+++ " ++ (normalizePath $ "b" </> name)) ++ "\n" ++
|
||||||
concatMap (formatRegion color LinefeedOk) most ++
|
concatMap (formatRegion color LinefeedOk) most ++
|
||||||
concatMap (formatRegion color lf) last
|
concatMap (formatRegion color lf) last
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user