Skip to content

Commit

Permalink
Don't automatically read stdin when the null input flag is used
Browse files Browse the repository at this point in the history
  • Loading branch information
mikefarah committed Apr 26, 2022
1 parent 90261a2 commit 70ad7a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions acceptance_tests/basic.sh
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmd/utils.go
Expand Up @@ -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
}

Expand Down

0 comments on commit 70ad7a3

Please sign in to comment.