Skip to content

Instantly share code, notes, and snippets.

@bokwoon95
Created January 28, 2023 12:06
Show Gist options
  • Save bokwoon95/dad321a4b699a67f95541ce7f65e73dc to your computer and use it in GitHub Desktop.
Save bokwoon95/dad321a4b699a67f95541ce7f65e73dc to your computer and use it in GitHub Desktop.
program to compare escaping between "github.com/frioux/shellquote" and "github.com/kballard/go-shellquote"
package main
import (
"fmt"
"os"
"github.com/frioux/shellquote"
gsq "github.com/kballard/go-shellquote"
)
// https://blog.afoolishmanifesto.com/posts/announcing-shellquote/
func main() {
q, err := shellquote.Quote(os.Args[1:])
if err != nil {
fmt.Fprintf(os.Stderr, "Couldn't quote with shellquote: %s\n", err)
os.Exit(1)
}
fmt.Println("shellquote:", q)
fmt.Println(" gsq:", gsq.Join(os.Args[1:]...))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment