Add support for making paths relative to cwd

Previously, all paths output by jiri grep were relative to jirix.Root,
which is rarely where I run jiri grep from. If I want to copy/paste a
path to open that file in my editor, I either need to do this in a
different terminal window that is at the jiri root, or I need to modify
the path.

This change adds a flag, -cwd-rel (defaulting off, so no default
behavior change) which makes the output paths relative to the current
directory. This allows me to easily select the matched path and paste it
in my current development context, which is my preferred mode of
operation.

If a user wishes to default to this behavior, that may be achieved by
creating a shell function like:

	function jgrep() {
		jiri grep -cwd-rel "$@"
	}

Change-Id: I8751bf0f8148f0088d35082f9fa8420ebea6c43a
diff --git a/cmd/jiri/grep.go b/cmd/jiri/grep.go
index a22830f..27a96bd 100644
--- a/cmd/jiri/grep.go
+++ b/cmd/jiri/grep.go
@@ -26,6 +26,7 @@
 }
 
 var grepFlags struct {
+	cwdRel bool
 	n bool
 	h bool
 	i bool
@@ -47,6 +48,7 @@
 	flags.BoolVar(&grepFlags.l, "files-with-matches", false, "same as -l")
 	flags.BoolVar(&grepFlags.L, "L", false, "Instead of showing every matched line, show only the names of files that do not contain matches")
 	flags.BoolVar(&grepFlags.L, "files-without-match", false, "same as -L")
+	flags.BoolVar(&grepFlags.cwdRel, "cwd-rel", false, "Output paths relative to the current working directory (if available)")
 }
 
 func buildFlags() []string {
@@ -118,8 +120,16 @@
 	if lenArgs == 1 {
 		query = args[0]
 	}
+
+	cwd := jirix.Root
+	if grepFlags.cwdRel {
+		if wd, err := os.Getwd(); err == nil {
+			cwd = wd
+		}
+	}
+
 	for _, project := range projects {
-		relpath, err := filepath.Rel(jirix.Root, project.Path)
+		relpath, err := filepath.Rel(cwd, project.Path)
 		if err != nil {
 			return nil, err
 		}