diff options
author | Jakob Unterwurzacher | 2017-04-29 15:11:17 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2017-04-29 15:11:17 +0200 |
commit | e135a72bda6ffa828e5445a16c349dd7017db282 (patch) | |
tree | 3637aa85f23a6431a014b3664394c437cd54650a /cli_args.go | |
parent | edb3e19cb5543c580261052395d461fa47c7cf58 (diff) |
main: "--" should also block "-o" parsing
Includes test cases.
Diffstat (limited to 'cli_args.go')
-rw-r--r-- | cli_args.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/cli_args.go b/cli_args.go index e42d9ae..e8fab75 100644 --- a/cli_args.go +++ b/cli_args.go @@ -36,11 +36,19 @@ var flagSet *flag.FlagSet // prefixOArgs transform options passed via "-o foo,bar" into regular options // like "-foo -bar" and prefixes them to the command line. +// Testcases in TestPrefixOArgs(). func prefixOArgs(osArgs []string) []string { - // Need at least 3, example: gocryptfs -o foo,bar + // Need at least 3, example: gocryptfs -o foo,bar + // ^ 0 ^ 1 ^ 2 if len(osArgs) < 3 { return osArgs } + // Passing "--" disables "-o" parsing. Ignore element 0 (program name). + for _, v := range osArgs[1:] { + if v == "--" { + return osArgs + } + } // Find and extract "-o foo,bar" var otherArgs, oOpts []string for i := 1; i < len(osArgs); i++ { |