summaryrefslogtreecommitdiff
path: root/cli_args.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2017-04-29 15:11:17 +0200
committerJakob Unterwurzacher2017-04-29 15:11:17 +0200
commite135a72bda6ffa828e5445a16c349dd7017db282 (patch)
tree3637aa85f23a6431a014b3664394c437cd54650a /cli_args.go
parentedb3e19cb5543c580261052395d461fa47c7cf58 (diff)
main: "--" should also block "-o" parsing
Includes test cases.
Diffstat (limited to 'cli_args.go')
-rw-r--r--cli_args.go10
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++ {