From 01deac9427d399b8ddd901ecaf31e01f06a6c10c Mon Sep 17 00:00:00 2001
From: Roman Proskuryakov <humbug@deeptown.org>
Date: Tue, 28 Mar 2017 19:06:30 +0300
Subject: [PATCH] Add -0 shortcut for --null

Fixes #419
---
 doc/rg.1.md    | 2 +-
 src/app.rs     | 2 +-
 tests/tests.rs | 9 +++++++++
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/doc/rg.1.md b/doc/rg.1.md
index 8e8ca289..658eef6a 100644
--- a/doc/rg.1.md
+++ b/doc/rg.1.md
@@ -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
diff --git a/src/app.rs b/src/app.rs
index d327e27c..19a243bf 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -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))
diff --git a/tests/tests.rs b/tests/tests.rs
index 9477f32e..1d0964b7 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -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");