Change exit status (0: OK, 1: No match, 2: Error/Interrupted)

A la grep. Close #345
This commit is contained in:
Junegunn Choi
2015-09-15 13:21:51 +09:00
parent fa2f9f1f21
commit 65d9d416b4
6 changed files with 76 additions and 20 deletions

View File

@@ -180,14 +180,14 @@ func defaultOptions() *Options {
Version: false}
}
func help(ok int) {
func help(code int) {
os.Stderr.WriteString(usage)
os.Exit(ok)
os.Exit(code)
}
func errorExit(msg string) {
os.Stderr.WriteString(msg + "\n")
os.Exit(1)
os.Exit(exitError)
}
func optString(arg string, prefixes ...string) (bool, string) {
@@ -682,7 +682,7 @@ func parseOptions(opts *Options, allArgs []string) {
arg := allArgs[i]
switch arg {
case "-h", "--help":
help(0)
help(exitOk)
case "-x", "--extended":
opts.Mode = ModeExtended
case "-e", "--extended-exact":