Generate Shell Commands in Go

Jmnote (토론 | 기여)님의 2022년 6월 2일 (목) 04:20 판 (→‎같이 보기)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요[ | ]

Generate Shell Commands in Go
Go
CPU
-1.0s
MEM
-0M
-1.0s
Copy
package main

import (
	"fmt"

	"github.com/keegancsmith/shell"
)

func main() {
	fmt.Println(shell.Sprintf("echo hello %S", []string{"foo.go", "bar.go", "| rm -rf /"}))
	fmt.Println(shell.Sprintf("echo hello %S", []string{"foo.go", "bar.go", "; rm -rf /"}))
	fmt.Println(shell.Sprintf("echo hello %S", []string{"foo.go", "bar.go", "'| rm -rf /"}))
	fmt.Println(shell.Sprintf("echo hello %S", []string{"foo.go", "bar.go", "'; rm -rf /"}))
	fmt.Println(shell.Sprintf("echo hello %S", []string{"foo.go", "bar.go", "'| rm -rf /'"}))
	fmt.Println(shell.Sprintf("echo hello %S", []string{"foo.go", "bar.go", "'; rm -rf /'"}))
}
echo hello foo.go bar.go '| rm -rf /'
echo hello foo.go bar.go '; rm -rf /'
echo hello foo.go bar.go ''\''| rm -rf /'
echo hello foo.go bar.go ''\''; rm -rf /'
echo hello foo.go bar.go ''\''| rm -rf /'\'''
echo hello foo.go bar.go ''\''; rm -rf /'\'''

2 같이 보기[ | ]

3 참고[ | ]