File tree Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## Unreleased
4
4
5
+ - A new ` shellQuote ` was added to the template system
6
+ (` {{shellQuote "a string"}} ` ) to ensure a string is safe for use in shell
7
+ (
[ mvdan/sh #727 ] ( https://github.com/mvdan/sh/pull/727 ) ,
[ mvdan/sh #737 ] ( https://github.com/mvdan/sh/pull/737 ) ,
[ Documentation
] ( https://pkg.go.dev/mvdan.cc/sh/[email protected] /syntax#Quote ) )
5
8
- In this version [ mvdan.cc/sh] ( https://github.com/mvdan/sh ) was upgraded
6
9
with some small fixes and features
7
10
- The ` read -p ` flag is now supported
Original file line number Diff line number Diff line change @@ -639,6 +639,9 @@ Task also adds the following functions:
639
639
converts a string from `/` path format to `\`.
640
640
- `exeExt` : Returns the right executable extension for the current OS
641
641
(`".exe"` for Windows, `""` for others).
642
+ - `shellQuote` : Quotes a string to make it safe for use in shell scripts.
643
+ Task uses [this Go function](https://pkg.go.dev/mvdan.cc/sh/[email protected] /syntax#Quote)
644
+ for this. The Bash dialect is assumed.
642
645
643
646
Example :
644
647
Original file line number Diff line number Diff line change 6
6
"strings"
7
7
"text/template"
8
8
9
- "github.com/go-task/slim-sprig"
9
+ sprig "github.com/go-task/slim-sprig"
10
+ "mvdan.cc/sh/v3/syntax"
10
11
)
11
12
12
13
var (
@@ -37,6 +38,9 @@ func init() {
37
38
}
38
39
return ""
39
40
},
41
+ "shellQuote" : func (str string ) (string , error ) {
42
+ return syntax .Quote (str , syntax .LangBash )
43
+ },
40
44
// IsSH is deprecated.
41
45
"IsSH" : func () bool { return true },
42
46
}
You can’t perform that action at this time.
0 commit comments