diff --git a/acceptance_tests/shebang.sh b/acceptance_tests/shebang.sh new file mode 100755 index 00000000..5d47e751 --- /dev/null +++ b/acceptance_tests/shebang.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +setUp() { + rm test*.yq || true + cat >test.yq <test.yml < 0 && maybeFile(args[0]) + + if expressionFile == "" && maybeFirstArgIsAFile && strings.HasSuffix(args[0], ".yq") { + // lets check if an expression file was given + yqlib.GetLogger().Debug("Assuming arg %v is an expression file", args[0]) + expressionFile = args[0] + args = args[1:] + } + if expressionFile != "" { expressionBytes, err := os.ReadFile(expressionFile) if err != nil { @@ -264,7 +274,6 @@ func processArgs(originalArgs []string) (string, []string, error) { expression = strings.ReplaceAll(string(expressionBytes), "\r\n", "\n") } - args := processStdInArgs(originalArgs) yqlib.GetLogger().Debugf("processed args: %v", args) if expression == "" && len(args) > 0 && args[0] != "-" && !maybeFile(args[0]) { yqlib.GetLogger().Debug("assuming expression is '%v'", args[0]) diff --git a/examples/environment.yq b/examples/environment.yq old mode 100644 new mode 100755 index 764f5802..81325364 --- a/examples/environment.yq +++ b/examples/environment.yq @@ -1,3 +1,4 @@ +#!yq .[] |( ( select(kind == "scalar") | key + "='" + . + "'"), ( select(kind == "seq") | key + "=(" + (map("'" + . + "'") | join(",")) + ")") diff --git a/test.yq b/test.yq new file mode 100755 index 00000000..0b1150b9 --- /dev/null +++ b/test.yq @@ -0,0 +1,2 @@ +#!./yq +.a.b