Commit 2eea1b05 authored by Lars Gierth's avatar Lars Gierth

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.
parent 4e0ca860
......@@ -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
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment