Don't automatically read stdin when the null input flag is used

This commit is contained in:
Mike Farah 2022-04-27 09:24:25 +10:00
parent 90261a2fdd
commit 70ad7a35a8
2 changed files with 7 additions and 1 deletions

View File

@ -86,6 +86,12 @@ testBasicCatWithFilesNoDash() {
assertEquals "$Y" "$X"
}
# when the nullinput flag is used
# dont automatically read STDIN (this breaks github actions)
testBasicCreateFileGithubAction() {
cat /dev/null | ./yq -n ".a = 123" > test.yml
}
testBasicEvalAllCatWithFilesNoDash() {
./yq -n ".a = 123" > test.yml
./yq -n ".a = 124" > test2.yml

View File

@ -126,7 +126,7 @@ func processStdInArgs(args []string) []string {
// read from stdin.
// this happens if there is more than one argument
// or only one argument and its a file
if !pipingStdin || len(args) > 1 || (len(args) > 0 && maybeFile(args[0])) {
if nullInput || !pipingStdin || len(args) > 1 || (len(args) > 0 && maybeFile(args[0])) {
return args
}