Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package yq for openSUSE:Factory checked in 
at 2023-07-18 22:09:07
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yq (Old)
 and      /work/SRC/openSUSE:Factory/.yq.new.3193 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "yq"

Tue Jul 18 22:09:07 2023 rev:11 rq:1099299 version:4.34.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/yq/yq.changes    2023-04-15 22:33:13.549565180 
+0200
+++ /work/SRC/openSUSE:Factory/.yq.new.3193/yq.changes  2023-07-18 
22:09:39.183501764 +0200
@@ -1,0 +2,10 @@
+Tue Jul 18 14:38:53 UTC 2023 - Dirk Müller <[email protected]>
+
+- update to 4.34.2:
+  * Bumped depedencies
+- update to 4.34.1:
+  * Added shell output format
+  * Fixed nil pointer dereference
+  * Bumped dependency versions
+
+-------------------------------------------------------------------

Old:
----
  yq-4.33.3.tar.gz

New:
----
  yq-4.34.2.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ yq.spec ++++++
--- /var/tmp/diff_new_pack.VWEBYc/_old  2023-07-18 22:09:39.883505677 +0200
+++ /var/tmp/diff_new_pack.VWEBYc/_new  2023-07-18 22:09:39.891505722 +0200
@@ -20,7 +20,7 @@
 %global import_path     %{provider_prefix}
 
 Name:           yq
-Version:        4.33.3
+Version:        4.34.2
 Release:        0
 Summary:        A portable command-line YAML processor
 License:        MIT

++++++ vendor.tar.gz ++++++
++++ 58497 lines of diff (skipped)

++++++ yq-4.33.3.tar.gz -> yq-4.34.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yq-4.33.3/CONTRIBUTING.md 
new/yq-4.34.2/CONTRIBUTING.md
--- old/yq-4.33.3/CONTRIBUTING.md       2023-04-11 04:06:26.000000000 +0200
+++ new/yq-4.34.2/CONTRIBUTING.md       2023-07-12 04:32:14.000000000 +0200
@@ -12,7 +12,7 @@
 
 # Documentation
 
-The documentation is a bit of a mixed bag (sorry in advanced, I do plan on 
simplifying it...) - with some parts automatically generated and stiched 
together and some statically defined.
+The documentation is a bit of a mixed bag (sorry in advance, I do plan on 
simplifying it...) - with some parts automatically generated and stiched 
together and some statically defined.
 
 Documentation is written in markdown, and is published in the 'gitbook' branch.
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yq-4.33.3/Dockerfile new/yq-4.34.2/Dockerfile
--- old/yq-4.33.3/Dockerfile    2023-04-11 04:06:26.000000000 +0200
+++ new/yq-4.34.2/Dockerfile    2023-07-12 04:32:14.000000000 +0200
@@ -1,4 +1,4 @@
-FROM golang:1.20.3 as builder
+FROM golang:1.20.5 as builder
 
 WORKDIR /go/src/mikefarah/yq
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yq-4.33.3/Dockerfile.dev new/yq-4.34.2/Dockerfile.dev
--- old/yq-4.33.3/Dockerfile.dev        2023-04-11 04:06:26.000000000 +0200
+++ new/yq-4.34.2/Dockerfile.dev        2023-07-12 04:32:14.000000000 +0200
@@ -1,4 +1,4 @@
-FROM golang:1.20.3
+FROM golang:1.20.5
 
 COPY scripts/devtools.sh /opt/devtools.sh
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yq-4.33.3/README.md new/yq-4.34.2/README.md
--- old/yq-4.33.3/README.md     2023-04-11 04:06:26.000000000 +0200
+++ new/yq-4.34.2/README.md     2023-07-12 04:32:14.000000000 +0200
@@ -362,5 +362,6 @@
 ## Known Issues / Missing Features
 - `yq` attempts to preserve comment positions and whitespace as much as 
possible, but it does not handle all scenarios (see 
https://github.com/go-yaml/yaml/tree/v3 for details)
 - Powershell has its own...[opinions on quoting 
yq](https://mikefarah.gitbook.io/yq/usage/tips-and-tricks#quotes-in-windows-powershell)
+- "yes", "no" were dropped as boolean values in the yaml 1.2 standard - which 
is the standard yq assumes.
 
 See [tips and tricks](https://mikefarah.gitbook.io/yq/usage/tips-and-tricks) 
for more common problems and solutions.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yq-4.33.3/cmd/utils.go new/yq-4.34.2/cmd/utils.go
--- old/yq-4.33.3/cmd/utils.go  2023-04-11 04:06:26.000000000 +0200
+++ new/yq-4.34.2/cmd/utils.go  2023-07-12 04:32:14.000000000 +0200
@@ -195,6 +195,8 @@
                return yqlib.NewXMLEncoder(indent, 
yqlib.ConfiguredXMLPreferences), nil
        case yqlib.TomlOutputFormat:
                return yqlib.NewTomlEncoder(), nil
+       case yqlib.ShellVariablesOutputFormat:
+               return yqlib.NewShellVariablesEncoder(), nil
        }
        return nil, fmt.Errorf("invalid encoder: %v", format)
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yq-4.33.3/cmd/version.go new/yq-4.34.2/cmd/version.go
--- old/yq-4.33.3/cmd/version.go        2023-04-11 04:06:26.000000000 +0200
+++ new/yq-4.34.2/cmd/version.go        2023-07-12 04:32:14.000000000 +0200
@@ -11,7 +11,7 @@
        GitDescribe string
 
        // Version is main version number that is being run at the moment.
-       Version = "v4.33.3"
+       Version = "v4.34.2"
 
        // VersionPrerelease is a pre-release marker for the version. If this 
is "" (empty string)
        // then it means that it is a final release. Otherwise, this is a 
pre-release
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yq-4.33.3/go.mod new/yq-4.34.2/go.mod
--- old/yq-4.33.3/go.mod        2023-04-11 04:06:26.000000000 +0200
+++ new/yq-4.34.2/go.mod        2023-07-12 04:32:14.000000000 +0200
@@ -11,11 +11,12 @@
        github.com/goccy/go-yaml v1.11.0
        github.com/jinzhu/copier v0.3.5
        github.com/magiconair/properties v1.8.7
-       github.com/pelletier/go-toml/v2 v2.0.7
+       github.com/pelletier/go-toml/v2 v2.0.8
        github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e
        github.com/spf13/cobra v1.7.0
        github.com/spf13/pflag v1.0.5
-       golang.org/x/net v0.8.0
+       golang.org/x/net v0.12.0
+       golang.org/x/text v0.11.0
        gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473
        gopkg.in/yaml.v3 v3.0.1
 )
@@ -24,8 +25,7 @@
        github.com/inconshreveable/mousetrap v1.1.0 // indirect
        github.com/mattn/go-colorable v0.1.13 // indirect
        github.com/mattn/go-isatty v0.0.17 // indirect
-       golang.org/x/sys v0.6.0 // indirect
-       golang.org/x/text v0.8.0 // indirect
+       golang.org/x/sys v0.10.0 // indirect
        golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
 )
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yq-4.33.3/go.sum new/yq-4.34.2/go.sum
--- old/yq-4.33.3/go.sum        2023-04-11 04:06:26.000000000 +0200
+++ new/yq-4.34.2/go.sum        2023-07-12 04:32:14.000000000 +0200
@@ -31,8 +31,8 @@
 github.com/mattn/go-isatty v0.0.16/go.mod 
h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
 github.com/mattn/go-isatty v0.0.17 
h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
 github.com/mattn/go-isatty v0.0.17/go.mod 
h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
-github.com/pelletier/go-toml/v2 v2.0.7 
h1:muncTPStnKRos5dpVKULv2FVd4bMOhNePj9CjgDb8Us=
-github.com/pelletier/go-toml/v2 v2.0.7/go.mod 
h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
+github.com/pelletier/go-toml/v2 v2.0.8 
h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ=
+github.com/pelletier/go-toml/v2 v2.0.8/go.mod 
h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4=
 github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e 
h1:aoZm08cpOy4WuID//EZDgcC4zIxODThtZNPirFr42+A=
 github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod 
h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
 github.com/pmezard/go-difflib v1.0.0 
h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@@ -48,15 +48,15 @@
 github.com/stretchr/testify v1.7.0/go.mod 
h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 github.com/stretchr/testify v1.7.1/go.mod 
h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 github.com/stretchr/testify v1.8.0/go.mod 
h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
-github.com/stretchr/testify v1.8.1 
h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
-github.com/stretchr/testify v1.8.1/go.mod 
h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
-golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
-golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
+github.com/stretchr/testify v1.8.3 
h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
+github.com/stretchr/testify v1.8.3/go.mod 
h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
+golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50=
+golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
 golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod 
h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
-golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
-golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
+golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
+golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
+golang.org/x/text v0.11.0/go.mod 
h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
 golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f 
h1:uF6paiQQebLeSXkrTqHqz0MXhXXS1KgF41eUdBNvxK0=
 golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f/go.mod 
h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 
h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yq-4.33.3/pkg/yqlib/decoder_json.go 
new/yq-4.34.2/pkg/yqlib/decoder_json.go
--- old/yq-4.33.3/pkg/yqlib/decoder_json.go     2023-04-11 04:06:26.000000000 
+0200
+++ new/yq-4.34.2/pkg/yqlib/decoder_json.go     2023-07-12 04:32:14.000000000 
+0200
@@ -46,6 +46,9 @@
 }
 
 func (dec *jsonDecoder) convertToYamlNode(data *orderedMap) (*yaml.Node, 
error) {
+       if data == nil {
+               return createScalarNode(nil, "null"), nil
+       }
        if data.kv == nil {
                switch rawData := data.altVal.(type) {
                case nil:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yq-4.33.3/pkg/yqlib/doc/operators/boolean-operators.md 
new/yq-4.34.2/pkg/yqlib/doc/operators/boolean-operators.md
--- old/yq-4.33.3/pkg/yqlib/doc/operators/boolean-operators.md  2023-04-11 
04:06:26.000000000 +0200
+++ new/yq-4.34.2/pkg/yqlib/doc/operators/boolean-operators.md  2023-07-12 
04:32:14.000000000 +0200
@@ -26,6 +26,24 @@
 true
 ```
 
+## "yes" and "no" are strings
+In the yaml 1.2 standard, support for yes/no as booleans was dropped - they 
are now considered strings. See '10.2.1.2. Boolean' in 
https://yaml.org/spec/1.2.2/
+
+Given a sample.yml file of:
+```yaml
+- yes
+- no
+```
+then
+```bash
+yq '.[] | tag' sample.yml
+```
+will output
+```yaml
+!!str
+!!str
+```
+
 ## `and` example
 Running
 ```bash
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yq-4.33.3/pkg/yqlib/doc/operators/encode-decode.md 
new/yq-4.34.2/pkg/yqlib/doc/operators/encode-decode.md
--- old/yq-4.33.3/pkg/yqlib/doc/operators/encode-decode.md      2023-04-11 
04:06:26.000000000 +0200
+++ new/yq-4.34.2/pkg/yqlib/doc/operators/encode-decode.md      2023-07-12 
04:32:14.000000000 +0200
@@ -25,7 +25,7 @@
 XML uses the `--xml-attribute-prefix` and `xml-content-name` flags to identify 
attributes and content fields.
 
 
-Base64 assumes [rfc4648](https://rfc-editor.org/rfc/rfc4648.html) encoding. 
Encoding and decoding both assume that the content is a string.
+Base64 assumes [rfc4648](https://rfc-editor.org/rfc/rfc4648.html) encoding. 
Encoding and decoding both assume that the content is a utf-8 string and not 
binary content.
 
 ## Encode value as json string
 Given a sample.yml file of:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yq-4.33.3/pkg/yqlib/doc/operators/headers/encode-decode.md 
new/yq-4.34.2/pkg/yqlib/doc/operators/headers/encode-decode.md
--- old/yq-4.33.3/pkg/yqlib/doc/operators/headers/encode-decode.md      
2023-04-11 04:06:26.000000000 +0200
+++ new/yq-4.34.2/pkg/yqlib/doc/operators/headers/encode-decode.md      
2023-07-12 04:32:14.000000000 +0200
@@ -25,4 +25,4 @@
 XML uses the `--xml-attribute-prefix` and `xml-content-name` flags to identify 
attributes and content fields.
 
 
-Base64 assumes [rfc4648](https://rfc-editor.org/rfc/rfc4648.html) encoding. 
Encoding and decoding both assume that the content is a string.
+Base64 assumes [rfc4648](https://rfc-editor.org/rfc/rfc4648.html) encoding. 
Encoding and decoding both assume that the content is a utf-8 string and not 
binary content.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yq-4.33.3/pkg/yqlib/doc/operators/headers/load.md 
new/yq-4.34.2/pkg/yqlib/doc/operators/headers/load.md
--- old/yq-4.33.3/pkg/yqlib/doc/operators/headers/load.md       2023-04-11 
04:06:26.000000000 +0200
+++ new/yq-4.34.2/pkg/yqlib/doc/operators/headers/load.md       2023-07-12 
04:32:14.000000000 +0200
@@ -14,6 +14,8 @@
 | Plain String | load_str |
 | Base64 | load_base64 |
 
+Note that load_base64 only works for base64 encoded utf-8 strings.
+
 ## Samples files for tests:
 
 ### yaml
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yq-4.33.3/pkg/yqlib/doc/operators/load.md 
new/yq-4.34.2/pkg/yqlib/doc/operators/load.md
--- old/yq-4.33.3/pkg/yqlib/doc/operators/load.md       2023-04-11 
04:06:26.000000000 +0200
+++ new/yq-4.34.2/pkg/yqlib/doc/operators/load.md       2023-07-12 
04:32:14.000000000 +0200
@@ -14,6 +14,8 @@
 | Plain String | load_str |
 | Base64 | load_base64 |
 
+Note that load_base64 only works for base64 encoded utf-8 strings.
+
 ## Samples files for tests:
 
 ### yaml
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yq-4.33.3/pkg/yqlib/doc/usage/shellvariables.md 
new/yq-4.34.2/pkg/yqlib/doc/usage/shellvariables.md
--- old/yq-4.33.3/pkg/yqlib/doc/usage/shellvariables.md 1970-01-01 
01:00:00.000000000 +0100
+++ new/yq-4.34.2/pkg/yqlib/doc/usage/shellvariables.md 2023-07-12 
04:32:14.000000000 +0200
@@ -0,0 +1,86 @@
+
+## Encode shell variables
+Note that comments are dropped and values will be enclosed in single quotes as 
needed.
+
+Given a sample.yml file of:
+```yaml
+# comment
+name: Mike Wazowski
+eyes:
+  color: turquoise
+  number: 1
+friends:
+  - James P. Sullivan
+  - Celia Mae
+```
+then
+```bash
+yq -o=shell sample.yml
+```
+will output
+```sh
+name='Mike Wazowski'
+eyes_color=turquoise
+eyes_number=1
+friends_0='James P. Sullivan'
+friends_1='Celia Mae'
+```
+
+## Encode shell variables: illegal variable names as key.
+Keys that would be illegal as variable keys are adapted.
+
+Given a sample.yml file of:
+```yaml
+ascii_=_symbols: replaced with _
+"ascii_        _controls": dropped (this example uses \t)
+nonascii_א_characters: dropped
+effrot_expeñded_tò_preserve_accented_latin_letters: moderate (via unicode 
NFKD)
+
+```
+then
+```bash
+yq -o=shell sample.yml
+```
+will output
+```sh
+ascii___symbols='replaced with _'
+ascii__controls='dropped (this example uses \t)'
+nonascii__characters=dropped
+effrot_expended_to_preserve_accented_latin_letters='moderate (via unicode 
NFKD)'
+```
+
+## Encode shell variables: empty values, arrays and maps
+Empty values are encoded to empty variables, but empty arrays and maps are 
skipped.
+
+Given a sample.yml file of:
+```yaml
+empty:
+  value:
+  array: []
+  map:   {}
+```
+then
+```bash
+yq -o=shell sample.yml
+```
+will output
+```sh
+empty_value=
+```
+
+## Encode shell variables: single quotes in values
+Single quotes in values are encoded as '"'"' (close single quote, 
double-quoted single quote, open single quote).
+
+Given a sample.yml file of:
+```yaml
+name: Miles O'Brien
+```
+then
+```bash
+yq -o=shell sample.yml
+```
+will output
+```sh
+name='Miles O'"'"'Brien'
+```
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yq-4.33.3/pkg/yqlib/encoder_shellvariables.go 
new/yq-4.34.2/pkg/yqlib/encoder_shellvariables.go
--- old/yq-4.33.3/pkg/yqlib/encoder_shellvariables.go   1970-01-01 
01:00:00.000000000 +0100
+++ new/yq-4.34.2/pkg/yqlib/encoder_shellvariables.go   2023-07-12 
04:32:14.000000000 +0200
@@ -0,0 +1,153 @@
+package yqlib
+
+import (
+       "fmt"
+       "io"
+       "strings"
+       "unicode/utf8"
+
+       "golang.org/x/text/unicode/norm"
+       yaml "gopkg.in/yaml.v3"
+)
+
+type shellVariablesEncoder struct {
+}
+
+func NewShellVariablesEncoder() Encoder {
+       return &shellVariablesEncoder{}
+}
+
+func (pe *shellVariablesEncoder) CanHandleAliases() bool {
+       return false
+}
+
+func (pe *shellVariablesEncoder) PrintDocumentSeparator(_ io.Writer) error {
+       return nil
+}
+
+func (pe *shellVariablesEncoder) PrintLeadingContent(_ io.Writer, _ string) 
error {
+       return nil
+}
+
+func (pe *shellVariablesEncoder) Encode(writer io.Writer, node *yaml.Node) 
error {
+
+       mapKeysToStrings(node)
+       err := pe.doEncode(&writer, node, "")
+       if err != nil {
+               return err
+       }
+
+       return err
+}
+
+func (pe *shellVariablesEncoder) doEncode(w *io.Writer, node *yaml.Node, path 
string) error {
+
+       // Note this drops all comments.
+
+       switch node.Kind {
+       case yaml.ScalarNode:
+               nonemptyPath := path
+               if path == "" {
+                       // We can't assign an empty variable "=somevalue" 
because that would error out if sourced in a shell,
+                       // nor can we use "_" as a variable name ($_ is a 
special shell variable that can't be assigned)...
+                       // let's just pick a fallback key to use if we are 
encoding a single scalar
+                       nonemptyPath = "value"
+               }
+               _, err := io.WriteString(*w, 
nonemptyPath+"="+quoteValue(node.Value)+"\n")
+               return err
+       case yaml.DocumentNode:
+               return pe.doEncode(w, node.Content[0], path)
+       case yaml.SequenceNode:
+               for index, child := range node.Content {
+                       err := pe.doEncode(w, child, appendPath(path, index))
+                       if err != nil {
+                               return err
+                       }
+               }
+               return nil
+       case yaml.MappingNode:
+               for index := 0; index < len(node.Content); index = index + 2 {
+                       key := node.Content[index]
+                       value := node.Content[index+1]
+                       err := pe.doEncode(w, value, appendPath(path, 
key.Value))
+                       if err != nil {
+                               return err
+                       }
+               }
+               return nil
+       case yaml.AliasNode:
+               return pe.doEncode(w, node.Alias, path)
+       default:
+               return fmt.Errorf("Unsupported node %v", node.Tag)
+       }
+}
+
+func appendPath(cookedPath string, rawKey interface{}) string {
+
+       // Shell variable names must match
+       //    [a-zA-Z_]+[a-zA-Z0-9_]*
+       //
+       // While this is not mandated by POSIX, which is quite lenient, it is
+       // what shells (for example busybox ash *) allow in practice.
+       //
+       // Since yaml names can contain basically any character, we will 
process them according to these steps:
+       //
+       //     1. apply unicode compatibility decomposition NFKD (this will 
convert accented
+       //        letters to letters followed by accents, split ligatures, 
replace exponents
+       //        with the corresponding digit, etc.
+       //
+       //     2. discard non-ASCII characters as well as ASCII control 
characters (ie. anything
+       //        with code point < 32 or > 126), this will eg. discard accents 
but keep the base
+       //        unaccented letter because of NFKD above
+       //
+       //     3. replace all non-alphanumeric characters with _
+       //
+       // Moreover, for the root key only, we will prepend an underscore if 
what results from the steps above
+       // does not start with [a-zA-Z_] (ie. if the root key starts with a 
digit).
+       //
+       // Note this is NOT a 1:1 mapping.
+       //
+       // (*) see endofname.c from 
https://git.busybox.net/busybox/tag/?h=1_36_0
+
+       // XXX empty strings
+
+       key := strings.Map(func(r rune) rune {
+               if isAlphaNumericOrUnderscore(r) {
+                       return r
+               } else if r < 32 || 126 < r {
+                       return -1
+               }
+               return '_'
+       }, norm.NFKD.String(fmt.Sprintf("%v", rawKey)))
+
+       if cookedPath == "" {
+               firstRune, _ := utf8.DecodeRuneInString(key)
+               if !isAlphaOrUnderscore(firstRune) {
+                       return "_" + key
+               }
+               return key
+       }
+       return cookedPath + "_" + key
+}
+
+func quoteValue(value string) string {
+       needsQuoting := false
+       for _, r := range value {
+               if !isAlphaNumericOrUnderscore(r) {
+                       needsQuoting = true
+                       break
+               }
+       }
+       if needsQuoting {
+               return "'" + strings.ReplaceAll(value, "'", "'\"'\"'") + "'"
+       }
+       return value
+}
+
+func isAlphaOrUnderscore(r rune) bool {
+       return ('a' <= r && r <= 'z') || ('A' <= r && r <= 'Z') || r == '_'
+}
+
+func isAlphaNumericOrUnderscore(r rune) bool {
+       return isAlphaOrUnderscore(r) || ('0' <= r && r <= '9')
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yq-4.33.3/pkg/yqlib/encoder_shellvariables_test.go 
new/yq-4.34.2/pkg/yqlib/encoder_shellvariables_test.go
--- old/yq-4.33.3/pkg/yqlib/encoder_shellvariables_test.go      1970-01-01 
01:00:00.000000000 +0100
+++ new/yq-4.34.2/pkg/yqlib/encoder_shellvariables_test.go      2023-07-12 
04:32:14.000000000 +0200
@@ -0,0 +1,93 @@
+package yqlib
+
+import (
+       "bufio"
+       "bytes"
+       "strings"
+       "testing"
+
+       "github.com/mikefarah/yq/v4/test"
+)
+
+func assertEncodesTo(t *testing.T, yaml string, shellvars string) {
+       var output bytes.Buffer
+       writer := bufio.NewWriter(&output)
+
+       var encoder = NewShellVariablesEncoder()
+       inputs, err := readDocuments(strings.NewReader(yaml), "test.yml", 0, 
NewYamlDecoder(ConfiguredYamlPreferences))
+       if err != nil {
+               panic(err)
+       }
+       node := inputs.Front().Value.(*CandidateNode).Node
+       err = encoder.Encode(writer, node)
+       if err != nil {
+               panic(err)
+       }
+       writer.Flush()
+
+       test.AssertResult(t, shellvars, strings.TrimSuffix(output.String(), 
"\n"))
+}
+
+func TestShellVariablesEncoderNonquoting(t *testing.T) {
+       assertEncodesTo(t, "a: alice", "a=alice")
+}
+
+func TestShellVariablesEncoderQuoting(t *testing.T) {
+       assertEncodesTo(t, "a: Lewis Carroll", "a='Lewis Carroll'")
+}
+
+func TestShellVariablesEncoderQuotesQuoting(t *testing.T) {
+       assertEncodesTo(t, "a: Lewis Carroll's Alice", "a='Lewis 
Carroll'\"'\"'s Alice'")
+}
+
+func TestShellVariablesEncoderStripComments(t *testing.T) {
+       assertEncodesTo(t, "a: Alice # comment", "a=Alice")
+}
+
+func TestShellVariablesEncoderMap(t *testing.T) {
+       assertEncodesTo(t, "a:\n b: Lewis\n c: Carroll", 
"a_b=Lewis\na_c=Carroll")
+}
+
+func TestShellVariablesEncoderArray_Unwrapped(t *testing.T) {
+       assertEncodesTo(t, "a: [{n: Alice}, {n: Bob}]", 
"a_0_n=Alice\na_1_n=Bob")
+}
+
+func TestShellVariablesEncoderKeyNonPrintable(t *testing.T) {
+       assertEncodesTo(t, `"be\all": ring!`, "bell='ring!'")
+}
+
+func TestShellVariablesEncoderKeyPrintableNonAlphaNumeric(t *testing.T) {
+       assertEncodesTo(t, `"b-e l=l": ring!`, "b_e_l_l='ring!'")
+}
+
+func TestShellVariablesEncoderKeyPrintableNonAscii(t *testing.T) {
+       assertEncodesTo(t, `"b\u00e9ll": ring!`, "bell='ring!'")
+}
+
+func TestShellVariablesEncoderRootKeyStartingWithDigit(t *testing.T) {
+       assertEncodesTo(t, "1a: onea", "_1a=onea")
+}
+
+func TestShellVariablesEncoderRootKeyStartingWithUnderscore(t *testing.T) {
+       assertEncodesTo(t, "_key: value", "_key=value")
+}
+
+func TestShellVariablesEncoderChildStartingWithUnderscore(t *testing.T) {
+       assertEncodesTo(t, "root:\n _child: value", "root__child=value")
+}
+
+func TestShellVariablesEncoderEmptyValue(t *testing.T) {
+       assertEncodesTo(t, "empty:", "empty=")
+}
+
+func TestShellVariablesEncoderEmptyArray(t *testing.T) {
+       assertEncodesTo(t, "empty: []", "")
+}
+
+func TestShellVariablesEncoderEmptyMap(t *testing.T) {
+       assertEncodesTo(t, "empty: {}", "")
+}
+
+func TestShellVariablesEncoderScalarNode(t *testing.T) {
+       assertEncodesTo(t, "some string", "value='some string'")
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yq-4.33.3/pkg/yqlib/json_test.go 
new/yq-4.34.2/pkg/yqlib/json_test.go
--- old/yq-4.33.3/pkg/yqlib/json_test.go        2023-04-11 04:06:26.000000000 
+0200
+++ new/yq-4.34.2/pkg/yqlib/json_test.go        2023-07-12 04:32:14.000000000 
+0200
@@ -81,6 +81,13 @@
 
 var jsonScenarios = []formatScenario{
        {
+               description:  "array null",
+               skipDoc:      true,
+               input:        "[null]",
+               scenarioType: "roundtrip-ndjson",
+               expected:     "[null]\n",
+       },
+       {
                description:  "set tags",
                skipDoc:      true,
                input:        "[{}]",
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yq-4.33.3/pkg/yqlib/operator_booleans_test.go 
new/yq-4.34.2/pkg/yqlib/operator_booleans_test.go
--- old/yq-4.33.3/pkg/yqlib/operator_booleans_test.go   2023-04-11 
04:06:26.000000000 +0200
+++ new/yq-4.34.2/pkg/yqlib/operator_booleans_test.go   2023-07-12 
04:32:14.000000000 +0200
@@ -13,6 +13,16 @@
                },
        },
        {
+               description:    "\"yes\" and \"no\" are strings",
+               subdescription: "In the yaml 1.2 standard, support for yes/no 
as booleans was dropped - they are now considered strings. See '10.2.1.2. 
Boolean' in https://yaml.org/spec/1.2.2/";,
+               document:       `[yes, no]`,
+               expression:     `.[] | tag`,
+               expected: []string{
+                       "D0, P[0], (!!str)::!!str\n",
+                       "D0, P[1], (!!str)::!!str\n",
+               },
+       },
+       {
                skipDoc:    true,
                document:   "b: hi",
                expression: `.a or .c`,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yq-4.33.3/pkg/yqlib/printer.go 
new/yq-4.34.2/pkg/yqlib/printer.go
--- old/yq-4.33.3/pkg/yqlib/printer.go  2023-04-11 04:06:26.000000000 +0200
+++ new/yq-4.34.2/pkg/yqlib/printer.go  2023-07-12 04:32:14.000000000 +0200
@@ -32,6 +32,7 @@
        UriOutputFormat
        ShOutputFormat
        TomlOutputFormat
+       ShellVariablesOutputFormat
 )
 
 func OutputFormatFromString(format string) (PrinterOutputFormat, error) {
@@ -50,8 +51,10 @@
                return XMLOutputFormat, nil
        case "toml":
                return TomlOutputFormat, nil
+       case "shell", "s", "sh":
+               return ShellVariablesOutputFormat, nil
        default:
-               return 0, fmt.Errorf("unknown format '%v' please use 
[yaml|json|props|csv|tsv|xml]", format)
+               return 0, fmt.Errorf("unknown format '%v' please use 
[yaml|json|props|csv|tsv|xml|toml|shell]", format)
        }
 }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yq-4.33.3/pkg/yqlib/shellvariables_test.go 
new/yq-4.34.2/pkg/yqlib/shellvariables_test.go
--- old/yq-4.33.3/pkg/yqlib/shellvariables_test.go      1970-01-01 
01:00:00.000000000 +0100
+++ new/yq-4.34.2/pkg/yqlib/shellvariables_test.go      2023-07-12 
04:32:14.000000000 +0200
@@ -0,0 +1,98 @@
+package yqlib
+
+import (
+       "bufio"
+       "fmt"
+       "testing"
+
+       "github.com/mikefarah/yq/v4/test"
+)
+
+var shellVariablesScenarios = []formatScenario{
+       {
+               description:    "Encode shell variables",
+               subdescription: "Note that comments are dropped and values will 
be enclosed in single quotes as needed.",
+               input: "" +
+                       "# comment" + "\n" +
+                       "name: Mike Wazowski" + "\n" +
+                       "eyes:" + "\n" +
+                       "  color: turquoise" + "\n" +
+                       "  number: 1" + "\n" +
+                       "friends:" + "\n" +
+                       "  - James P. Sullivan" + "\n" +
+                       "  - Celia Mae",
+               expected: "" +
+                       "name='Mike Wazowski'" + "\n" +
+                       "eyes_color=turquoise" + "\n" +
+                       "eyes_number=1" + "\n" +
+                       "friends_0='James P. Sullivan'" + "\n" +
+                       "friends_1='Celia Mae'" + "\n",
+       },
+       {
+               description:    "Encode shell variables: illegal variable names 
as key.",
+               subdescription: "Keys that would be illegal as variable keys 
are adapted.",
+               input: "" +
+                       "ascii_=_symbols: replaced with _" + "\n" +
+                       "\"ascii_\t_controls\": dropped (this example uses 
\\t)" + "\n" +
+                       "nonascii_\u05d0_characters: dropped" + "\n" +
+                       
"effrot_expe\u00f1ded_t\u00f2_preserve_accented_latin_letters: moderate (via 
unicode NFKD)" + "\n",
+               expected: "" +
+                       "ascii___symbols='replaced with _'" + "\n" +
+                       "ascii__controls='dropped (this example uses \\t)'" + 
"\n" +
+                       "nonascii__characters=dropped" + "\n" +
+                       
"effrot_expended_to_preserve_accented_latin_letters='moderate (via unicode 
NFKD)'" + "\n",
+       },
+       {
+               description:    "Encode shell variables: empty values, arrays 
and maps",
+               subdescription: "Empty values are encoded to empty variables, 
but empty arrays and maps are skipped.",
+               input:          "empty:\n  value:\n  array: []\n  map:   {}",
+               expected:       "empty_value=" + "\n",
+       },
+       {
+               description:    "Encode shell variables: single quotes in 
values",
+               subdescription: "Single quotes in values are encoded as '\"'\"' 
(close single quote, double-quoted single quote, open single quote).",
+               input:          "name: Miles O'Brien",
+               expected:       `name='Miles O'"'"'Brien'` + "\n",
+       },
+}
+
+func TestShellVariableScenarios(t *testing.T) {
+       for _, s := range shellVariablesScenarios {
+               //fmt.Printf("\t<%s> <%s>\n", s.expected, 
mustProcessFormatScenario(s, NewYamlDecoder(ConfiguredYamlPreferences), 
NewShellVariablesEncoder()))
+               test.AssertResultWithContext(t, s.expected, 
mustProcessFormatScenario(s, NewYamlDecoder(ConfiguredYamlPreferences), 
NewShellVariablesEncoder()), s.description)
+       }
+       genericScenarios := make([]interface{}, len(shellVariablesScenarios))
+       for i, s := range shellVariablesScenarios {
+               genericScenarios[i] = s
+       }
+       documentScenarios(t, "usage", "shellvariables", genericScenarios, 
documentShellVaraibleScenario)
+}
+
+func documentShellVaraibleScenario(_ *testing.T, w *bufio.Writer, i 
interface{}) {
+       s := i.(formatScenario)
+       if s.skipDoc {
+               return
+       }
+       writeOrPanic(w, fmt.Sprintf("## %v\n", s.description))
+
+       if s.subdescription != "" {
+               writeOrPanic(w, s.subdescription)
+               writeOrPanic(w, "\n\n")
+       }
+
+       writeOrPanic(w, "Given a sample.yml file of:\n")
+       writeOrPanic(w, fmt.Sprintf("```yaml\n%v\n```\n", s.input))
+
+       writeOrPanic(w, "then\n")
+
+       expression := s.expression
+
+       if expression != "" {
+               writeOrPanic(w, fmt.Sprintf("```bash\nyq -o=shell '%v' 
sample.yml\n```\n", expression))
+       } else {
+               writeOrPanic(w, "```bash\nyq -o=shell sample.yml\n```\n")
+       }
+       writeOrPanic(w, "will output\n")
+
+       writeOrPanic(w, fmt.Sprintf("```sh\n%v```\n\n", 
mustProcessFormatScenario(s, NewYamlDecoder(ConfiguredYamlPreferences), 
NewShellVariablesEncoder())))
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yq-4.33.3/pkg/yqlib/utils.go 
new/yq-4.34.2/pkg/yqlib/utils.go
--- old/yq-4.33.3/pkg/yqlib/utils.go    2023-04-11 04:06:26.000000000 +0200
+++ new/yq-4.34.2/pkg/yqlib/utils.go    2023-07-12 04:32:14.000000000 +0200
@@ -15,7 +15,7 @@
                reader = bufio.NewReader(os.Stdin)
        } else {
                // ignore CWE-22 gosec issue - that's more targeted for http 
based apps that run in a public directory,
-               // and ensuring that it's not possible to give a path to a file 
outside thar directory.
+               // and ensuring that it's not possible to give a path to a file 
outside that directory.
                file, err := os.Open(filename) // #nosec
                if err != nil {
                        return nil, err
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yq-4.33.3/release_notes.txt 
new/yq-4.34.2/release_notes.txt
--- old/yq-4.33.3/release_notes.txt     2023-04-11 04:06:26.000000000 +0200
+++ new/yq-4.34.2/release_notes.txt     2023-07-12 04:32:14.000000000 +0200
@@ -1,3 +1,12 @@
+4.34.2:
+  - Bumped dependencies
+
+
+4.34.1:
+  - Added shell output format thanks @giorgiga
+  - Fixed nil pointer dereference (#1649) thanks @ArthurFritz
+  - Bumped dependency versions
+
 4.33.3:
   - Fixed bug when splatting empty array #1613
   - Added scalar output for TOML (#1617)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yq-4.33.3/snap/snapcraft.yaml 
new/yq-4.34.2/snap/snapcraft.yaml
--- old/yq-4.33.3/snap/snapcraft.yaml   2023-04-11 04:06:26.000000000 +0200
+++ new/yq-4.34.2/snap/snapcraft.yaml   2023-07-12 04:32:14.000000000 +0200
@@ -1,5 +1,5 @@
 name: yq
-version: 'v4.33.3'
+version: 'v4.34.2'
 summary: A lightweight and portable command-line YAML processor
 description: |
   The aim of the project is to be the jq or sed of yaml files.

Reply via email to