mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
No longer auto-read from STDIN if there are files given (#1115)
This commit is contained in:
parent
75fffc17e1
commit
304fc462a4
@ -62,11 +62,16 @@ testBasicEvalAllAllFiles() {
|
|||||||
assertEquals "$Y" "$X"
|
assertEquals "$Y" "$X"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# when given a file, don't read STDIN
|
||||||
|
# otherwise strange things start happening
|
||||||
|
# in scripts
|
||||||
|
# https://github.com/mikefarah/yq/issues/1115
|
||||||
|
|
||||||
testBasicCatWithFilesNoDash() {
|
testBasicCatWithFilesNoDash() {
|
||||||
./yq -n ".a = 123" > test.yml
|
./yq -n ".a = 123" > test.yml
|
||||||
./yq -n ".a = 124" > test2.yml
|
./yq -n ".a = 124" > test2.yml
|
||||||
X=$(cat test.yml | ./yq test2.yml)
|
X=$(cat test.yml | ./yq test2.yml)
|
||||||
Y=$(./yq e '.' test2.yml test.yml)
|
Y=$(./yq e '.' test2.yml)
|
||||||
assertEquals "$Y" "$X"
|
assertEquals "$Y" "$X"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +79,7 @@ testBasicEvalAllCatWithFilesNoDash() {
|
|||||||
./yq -n ".a = 123" > test.yml
|
./yq -n ".a = 123" > test.yml
|
||||||
./yq -n ".a = 124" > test2.yml
|
./yq -n ".a = 124" > test2.yml
|
||||||
X=$(cat test.yml | ./yq ea test2.yml)
|
X=$(cat test.yml | ./yq ea test2.yml)
|
||||||
Y=$(./yq e '.' test2.yml test.yml)
|
Y=$(./yq e '.' test2.yml)
|
||||||
assertEquals "$Y" "$X"
|
assertEquals "$Y" "$X"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +87,7 @@ testBasicCatWithFilesNoDashWithExp() {
|
|||||||
./yq -n ".a = 123" > test.yml
|
./yq -n ".a = 123" > test.yml
|
||||||
./yq -n ".a = 124" > test2.yml
|
./yq -n ".a = 124" > test2.yml
|
||||||
X=$(cat test.yml | ./yq '.a' test2.yml)
|
X=$(cat test.yml | ./yq '.a' test2.yml)
|
||||||
Y=$(./yq e '.a' test2.yml test.yml)
|
Y=$(./yq e '.a' test2.yml)
|
||||||
assertEquals "$Y" "$X"
|
assertEquals "$Y" "$X"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +95,7 @@ testBasicEvalAllCatWithFilesNoDashWithExp() {
|
|||||||
./yq -n ".a = 123" > test.yml
|
./yq -n ".a = 123" > test.yml
|
||||||
./yq -n ".a = 124" > test2.yml
|
./yq -n ".a = 124" > test2.yml
|
||||||
X=$(cat test.yml | ./yq ea '.a' test2.yml)
|
X=$(cat test.yml | ./yq ea '.a' test2.yml)
|
||||||
Y=$(./yq e '.a' test2.yml test.yml)
|
Y=$(./yq e '.a' test2.yml)
|
||||||
assertEquals "$Y" "$X"
|
assertEquals "$Y" "$X"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +117,11 @@ func maybeFile(str string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func processStdInArgs(pipingStdin bool, args []string) []string {
|
func processStdInArgs(pipingStdin bool, args []string) []string {
|
||||||
if !pipingStdin {
|
// if we've been given a file, don't automatically
|
||||||
|
// 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])) {
|
||||||
return args
|
return args
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user