Skip to content

Commit ba5c415

Browse files
committed
Allow specifying color= in shellcheckrc (closes #2350)
Signed-off-by: Olliver Schinagl <[email protected]>
1 parent 6f7eee4 commit ba5c415

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## Git (0.8.0)
22
### Added
3+
- `color=` directive can be added to .shellceckrc
34
- `disable=all` now conveniently disables all warnings
45
- `external-sources=true` directive can be added to .shellcheckrc to make
56
shellcheck behave as if `-x` was specified.

Diff for: shellcheck.1.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ not warn at all, as `ksh` supports decimals in arithmetic contexts.
4141

4242
: For TTY output, enable colors *always*, *never* or *auto*. The default
4343
is *auto*. **--color** without an argument is equivalent to
44-
**--color=always**.
44+
**--color=auto**.
45+
46+
This option may also be enabled using `color=` in
47+
`.shellcheckrc`. This flag takes precedence.
4548

4649
**-i**\ *CODE1*[,*CODE2*...],\ **--include=***CODE1*[,*CODE2*...]
4750

@@ -232,6 +235,10 @@ Here a shell brace group is used to suppress a warning on multiple lines:
232235

233236
Valid keys are:
234237

238+
**color**
239+
: Set to `auto`, `never` or `always` in `.shellcheckrc` to automatically
240+
detect, never or always use color output with the `tty` output format.
241+
235242
**disable**
236243
: Disables a comma separated list of error codes for the following command.
237244
The command can be a simple command like `echo foo`, or a compound command
@@ -277,6 +284,9 @@ it will read `key=value` pairs from it and treat them as file-wide directives.
277284

278285
Here is an example `.shellcheckrc`:
279286

287+
# Always force color output on the tty output
288+
color=always
289+
280290
# Look for 'source'd files relative to the checked script,
281291
# and also look for absolute paths in /mnt/chroot
282292
source-path=SCRIPTDIR

Diff for: src/ShellCheck/Parser.hs

+8
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,14 @@ readAnnotationWithoutPrefix sandboxed = do
10051005
key <- many1 (letter <|> char '-')
10061006
char '=' <|> fail "Expected '=' after directive key"
10071007
annotations <- case key of
1008+
"color" -> do
1009+
color <- many1 $ noneOf " \n"
1010+
option <- parseColorOption color
1011+
return options {
1012+
formatterOptions = (formatterOptions options) {
1013+
foColorOption = option
1014+
}
1015+
}
10081016
"disable" -> readElement `sepBy` char ','
10091017
where
10101018
readElement = readRange <|> readAll

0 commit comments

Comments
 (0)