mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
parse: fix handling of unwanted stdin
There can be non-terminal (i.e. non-interactive) sessions that are *not* a pipe, for example: ssh user@host ipfs version In this case, it looks like we should read from stdin. Parsing stdin is accomplished by deliberately triggering the parsing loop once. We didn't previously check whether there is an ArgDef to support that loop iteration.
This commit is contained in:
parent
4e0ca860e9
commit
2eea1b05b7
@ -219,9 +219,11 @@ func parseArgs(inputs []string, stdin *os.File, argDefs []cmds.Argument, recursi
|
||||
}
|
||||
}
|
||||
|
||||
// count number of values provided by user
|
||||
// count number of values provided by user.
|
||||
// if there is at least one ArgDef, we can safely trigger the inputs loop
|
||||
// below to parse stdin.
|
||||
numInputs := len(inputs)
|
||||
if stdin != nil {
|
||||
if argDef := getArgDef(0, argDefs); argDef != nil && stdin != nil {
|
||||
numInputs += 1
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user