Skip to content

Respect TERM=dumb and emit no colour escape codes #847

@andreastt

Description

@andreastt

Certain shells are not particularly happy with colour escape codes. To make them happy, clap should respect TERM=dumb and refrain from emitting colour escape codes.

Rust Version

rustc 1.15.0 (10893a9a3 2017-01-19)

Affected Version of clap

% grep clap Cargo.toml
clap = "2.19.0"

Expected Behavior Summary

For a program using clap to respect TERM=dumb and emit no colour escape codes.

Actual Behavior Summary

Program using clap emits colour escape codes as shown in BurntSushi/ripgrep#353.

Steps to Reproduce the issue

Compile any program using clap as a dependency and use an unrecognised flag:

% rg --color never -asd
�[1;31merror:�[0m Found argument '�[33m-d�[0m' which wasn't expected, or isn't valid in this context

USAGE:
    
    rg [OPTIONS] <pattern> [<path> ...]
    rg [OPTIONS] [-e PATTERN | -f FILE ]... [<path> ...]
    rg [OPTIONS] --files [<path> ...]
    rg [OPTIONS] --type-list

For more information try �[32m--help�[0m

Metadata

Metadata

Assignees

Labels

C-enhancementCategory: Raise on the bar on expectations

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions