Added shell string encoder (@sh) #1526

This commit is contained in:
Mike Farah
2023-02-02 12:23:08 +11:00
parent d119dbc239
commit d21bb920d6
7 changed files with 75 additions and 0 deletions
+17
View File
@@ -17,6 +17,7 @@ These operators are useful to process yaml documents that have stringified embed
| XML | from_xml/@xmld | to_xml(i)/@xml |
| Base64 | @base64d | @base64 |
| URI | @urid | @uri |
| Shell | | @sh |
See CSV and TSV [documentation](https://mikefarah.gitbook.io/yq/usage/csv-tsv) for accepted formats.
@@ -464,6 +465,22 @@ will output
this has & special () characters *
```
## Encode a string to sh
Sh/Bash friendly string
Given a sample.yml file of:
```yaml
coolData: strings with spaces and a 'quote'
```
then
```bash
yq '.coolData | @sh' sample.yml
```
will output
```yaml
'strings with spaces and a \'quote\''
```
## Decode a base64 encoded string
Decoded data is assumed to be a string.