Skip to content

Commit

Permalink
Add -0 shortcut for --null
Browse files Browse the repository at this point in the history
  • Loading branch information
kpp committed Mar 28, 2017
1 parent b4bc3b6 commit 3081f71
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion doc/rg.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ Project home page: https://github.com/BurntSushi/ripgrep
: Don't respect version control ignore files (e.g., .gitignore).
Note that .ignore files will continue to be respected.

--null
-0, --null
: Whenever a file name is printed, follow it with a NUL byte.
This includes printing filenames before matches, and when printing
a list of matching files such as with --count, --files-with-matches
Expand Down
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ fn app<F>(next_line_help: bool, doc: F) -> App<'static, 'static>
.arg(flag("no-ignore"))
.arg(flag("no-ignore-parent"))
.arg(flag("no-ignore-vcs"))
.arg(flag("null"))
.arg(flag("null").short("0"))
.arg(flag("path-separator").value_name("SEPARATOR").takes_value(true))
.arg(flag("pretty").short("p"))
.arg(flag("replace").short("r").value_name("ARG").takes_value(true))
Expand Down
9 changes: 9 additions & 0 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1390,6 +1390,15 @@ clean!(feature_275_pathsep, "test", ".", |wd: WorkDir, mut cmd: Command| {
assert_eq!(lines, "fooZbar:test\n");
});

// See: https://github.com/BurntSushi/ripgrep/issues/419
sherlock!(feature_419_zero_as_shortcut_for_null, "Sherlock", ".",
|wd: WorkDir, mut cmd: Command| {
cmd.arg("-0").arg("--count");

let lines: String = wd.stdout(&mut cmd);
assert_eq!(lines, "sherlock\x002\n");
});

#[test]
fn binary_nosearch() {
let wd = WorkDir::new("binary_nosearch");
Expand Down

0 comments on commit 3081f71

Please sign in to comment.