Fixed bug in alternative op, dont evaluate RHS if LHS is truthy

This commit is contained in:
Mike Farah
2022-09-09 11:05:12 +10:00
parent a12c1a6610
commit a64eea3b1a
3 changed files with 69 additions and 1 deletions
@@ -79,3 +79,36 @@ will output
cat
```
## Update or create - entity exists
This initialises `a` if it's not present
Given a sample.yml file of:
```yaml
a: 1
```
then
```bash
yq '(.a // (.a = 0)) += 1' sample.yml
```
will output
```yaml
a: 2
```
## Update or create - entity does not exist
This initialises `a` if it's not present
Given a sample.yml file of:
```yaml
b: camel
```
then
```bash
yq '(.a // (.a = 0)) += 1' sample.yml
```
will output
```yaml
b: camel
a: 1
```