From 571e136c954358a53dd1816134731611f584734b Mon Sep 17 00:00:00 2001 From: Charles Duffy Date: Sun, 25 Aug 2019 22:16:19 -0500 Subject: Implement shell-compatible quoting (#587) * Implement shell-compatible quoting * Reorganize to move non-template-specific logic from funcs/strings to strings/strings --- docs-src/content/functions/strings.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'docs-src') diff --git a/docs-src/content/functions/strings.yml b/docs-src/content/functions/strings.yml index b3062dc4..e2532a17 100644 --- a/docs-src/content/functions/strings.yml +++ b/docs-src/content/functions/strings.yml @@ -252,6 +252,24 @@ funcs: - | $ echo 'Rock & Roll @ Cafe Wha?' | gomplate -d in=stdin: -i '{{ strings.Slug (include "in") }}' rock-and-roll-at-cafe-wha + - name: strings.ShellQuote + alias: shellQuote + description: | + Given a string, emits a version of that string that will evaluate to its literal data when expanded by any POSIX-compliant shell. + + Given an array or slice, emit a single string which will evaluate to a series of shell words, one per item in that array or slice. + pipeline: true + arguments: + - name: in + required: true + description: The input to quote + examples: + - | + $ gomplate -i "{{ slice \"one word\" \"foo='bar baz'\" | shellQuote }}" + 'one word' 'foo='"'"'bar baz'"'"'' + - | + $ gomplate -i "{{ strings.ShellQuote \"it's a banana\" }}" + 'it'"'"'s a banana' - name: strings.Squote alias: squote description: | -- cgit v1.2.3