github.com/telepresenceio/telepresence/v2@v2.20.0-pro.6.0.20240517030216-236ea954e789/pkg/shellquote/shellstring.go (about)

     1  package shellquote
     2  
     3  import (
     4  	"strings"
     5  )
     6  
     7  func ShellString(exe string, args []string) string {
     8  	b := strings.Builder{}
     9  	b.WriteString(quoteArg(exe))
    10  	for _, a := range args {
    11  		b.WriteByte(' ')
    12  		b.WriteString(quoteArg(a))
    13  	}
    14  	return b.String()
    15  }
    16  
    17  func ShellArgsString(args []string) string {
    18  	b := strings.Builder{}
    19  	for i, a := range args {
    20  		if i > 0 {
    21  			b.WriteByte(' ')
    22  		}
    23  		b.WriteString(quoteArg(a))
    24  	}
    25  	return b.String()
    26  }