Files
Anand Kumar Singh 722020678f Migrate to ginkgo v2 (#5809)
* migrate to ginkgo v2 for tests

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* update to ginkgo/v2

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* update to ginkgo v2

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* use ginkgo binary for tests

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* update to ginkgo v2

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* remove GOFLAG while downloading ginkgo

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* remove FlakeAttempts from tests

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* use ginkgo v2.1.4

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* mod cleanup and use mod to run ginkgo

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* remove unnecessary goget-ginkgo from sctipt

Signed-off-by: anandrkskd <anandrkskd@gmail.com>
2022-07-06 10:31:01 +00:00
..
2022-07-06 10:31:01 +00:00
2022-07-06 10:31:01 +00:00
2022-07-06 10:31:01 +00:00
2022-07-06 10:31:01 +00:00
2022-07-06 10:31:01 +00:00
2022-07-06 10:31:01 +00:00
2022-07-06 10:31:01 +00:00

Build GoDoc sourcegraph codecov Coverage Go Report Card

shellescape

Escape arbitrary strings for safe use as command line arguments.

Contents of the package

This package provides the shellescape.Quote() function that returns a shell-escaped copy of a string. This functionality could be helpful in those cases where it is known that the output of a Go program will be appended to/used in the context of shell programs' command line arguments.

This work was inspired by the Python original package shellescape.

Usage

The following snippet shows a typical unsafe idiom:

package main

import (
	"fmt"
	"os"
)

func main() {
	fmt.Printf("ls -l %s\n", os.Args[1])
}

See in Go Playground

Especially when creating pipeline of commands which might end up being executed by a shell interpreter, it is particularly unsafe to not escape arguments.

shellescape.Quote() comes in handy and to safely escape strings:

package main

import (
        "fmt"
        "os"

        "gopkg.in/alessio/shellescape.v1"
)

func main() {
        fmt.Printf("ls -l %s\n", shellescape.Quote(os.Args[1]))
}

See in Go Playground

The escargs utility

escargs reads lines from the standard input and prints shell-escaped versions. Unlinke xargs, blank lines on the standard input are not discarded.