This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git


The following commit(s) were added to refs/heads/master by this push:
     new 8480d7d  executeShell: escape also '<' and '>'
8480d7d is described below

commit 8480d7d022edf27bff7693e812828f940a3df85c
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Wed Jun 23 14:04:21 2021 +0200

    executeShell: escape also '<' and '>'
    
    option --executeShell escaped quotation marks
    on lines that were passed to bin/sh.
    
    This also escapes '<' and '>' before running sh.
    This allows to have cflags in the form
    -DMBEDTLS_USER_CONFIG_FILE=<mbedtls/config_mynewt.h>
---
 util/util.go | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/util/util.go b/util/util.go
index d693f1a..05c8530 100644
--- a/util/util.go
+++ b/util/util.go
@@ -367,7 +367,10 @@ func ShellCommandLimitDbgOutput(
        if ExecuteShell && (runtime.GOOS == "linux" || runtime.GOOS == 
"darwin") {
                cmd := strings.Join(cmdStrs, " ")
                name = "/bin/sh"
-               args = []string{"-c", strings.Replace(cmd, "\"", "\\\"", -1)}
+               cmd = strings.Replace(cmd, "\"", "\\\"", -1)
+               cmd = strings.Replace(cmd, "<", "\\<", -1)
+               cmd = strings.Replace(cmd, ">", "\\>", -1)
+               args = []string{"-c", cmd}
        } else {
                if strings.HasSuffix(cmdStrs[0], ".sh") {
                        var newt_sh = os.Getenv("NEWT_SH")

Reply via email to