Skip to content

Commit

Permalink
main: pull regular exits into main function
Browse files Browse the repository at this point in the history
The replaces the "does not return" comments with
an explicit os.Exit, which is unambigous.
  • Loading branch information
rfjakob committed Apr 1, 2018
1 parent 1a3d04a commit 5da5e46
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
1 change: 0 additions & 1 deletion info.go
Expand Up @@ -41,5 +41,4 @@ func info(filename string) {
s := cf.ScryptObject
fmt.Printf("ScryptObject: Salt=%dB N=%d R=%d P=%d KeyLen=%d\n",
len(s.Salt), s.N, s.R, s.P, s.KeyLen)
os.Exit(0)
}
1 change: 0 additions & 1 deletion init_dir.go
Expand Up @@ -79,5 +79,4 @@ func initDir(args *argContainer) {
}
tlog.Info.Printf(tlog.ColorGrey+"You can now mount it using: %s%s %s MOUNTPOINT"+tlog.ColorReset,
tlog.ProgramName, mountArgs, friendlyPath)
os.Exit(0)
}
10 changes: 6 additions & 4 deletions main.go
Expand Up @@ -103,7 +103,6 @@ func changePassword(args *argContainer) {
os.Exit(exitcodes.WriteConf)
}
tlog.Info.Printf(tlog.ColorGreen + "Password changed." + tlog.ColorReset)
os.Exit(0)
}

// printVersion prints a version string like this:
Expand Down Expand Up @@ -257,23 +256,26 @@ func main() {
tlog.Fatal.Printf("Usage: %s -info CIPHERDIR", tlog.ProgramName)
os.Exit(exitcodes.Usage)
}
info(args.config) // does not return
info(args.config)
os.Exit(0)
}
// "-init"
if args.init {
if flagSet.NArg() > 1 {
tlog.Fatal.Printf("Usage: %s -init [OPTIONS] CIPHERDIR", tlog.ProgramName)
os.Exit(exitcodes.Usage)
}
initDir(&args) // does not return
initDir(&args)
os.Exit(0)
}
// "-passwd"
if args.passwd {
if flagSet.NArg() > 1 {
tlog.Fatal.Printf("Usage: %s -passwd [OPTIONS] CIPHERDIR", tlog.ProgramName)
os.Exit(exitcodes.Usage)
}
changePassword(&args) // does not return
changePassword(&args)
os.Exit(0)
}
// Default operation: mount.
if flagSet.NArg() != 2 {
Expand Down

0 comments on commit 5da5e46

Please sign in to comment.