mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #3175 from xiang90/2.2-ctl-bug
etcdctl: fix exec watch command
This commit is contained in:
commit
58bc617dd0
@ -51,21 +51,35 @@ func execWatchCommandFunc(c *cli.Context, ki client.KeysAPI) {
|
||||
handleError(ExitBadArgs, errors.New("key and command to exec required"))
|
||||
}
|
||||
|
||||
key := args[argslen-1]
|
||||
cmdArgs := args[:argslen-1]
|
||||
var (
|
||||
key string
|
||||
cmdArgs []string
|
||||
)
|
||||
|
||||
foundSep := false
|
||||
for i := range args {
|
||||
if args[i] == "--" && i != 0 {
|
||||
foundSep = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if foundSep {
|
||||
key = args[0]
|
||||
cmdArgs = args[2:]
|
||||
} else {
|
||||
// If no flag is parsed, the order of key and cmdArgs will be switched and
|
||||
// args will not contain `--`.
|
||||
key = args[argslen-1]
|
||||
cmdArgs = args[:argslen-1]
|
||||
}
|
||||
|
||||
index := 0
|
||||
if c.Int("after-index") != 0 {
|
||||
index = c.Int("after-index") + 1
|
||||
key = args[0]
|
||||
cmdArgs = args[2:]
|
||||
}
|
||||
|
||||
recursive := c.Bool("recursive")
|
||||
if recursive != false {
|
||||
key = args[0]
|
||||
cmdArgs = args[2:]
|
||||
}
|
||||
|
||||
sigch := make(chan os.Signal, 1)
|
||||
signal.Notify(sigch, os.Interrupt)
|
||||
|
Loading…
x
Reference in New Issue
Block a user