Created
January 28, 2023 12:06
-
-
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"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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