All Projects → alessio → shellescape

alessio / shellescape

Licence: MIT license
Escape arbitrary strings for use as command line arguments

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to shellescape

CombinedPrivacyBlockLists
Ad-blocking hosts files, IP block lists, PAC filters, and ABP / uBO subscriptions, all merged from multiple reputable sources, combined with my own research. Also, script-based utilities to help you create such things yourself. Updated at least once a week, often more frequently.
Stars: ✭ 131 (+9.17%)
Mutual labels:  shell-scripting
courses
Notes for classes/lectures
Stars: ✭ 14 (-88.33%)
Mutual labels:  shell-scripting
Babashka
Native, fast starting Clojure interpreter for scripting
Stars: ✭ 2,462 (+1951.67%)
Mutual labels:  shell-scripting
Script
Making it easy to write shell-like scripts in Go
Stars: ✭ 1,946 (+1521.67%)
Mutual labels:  shell-scripting
smoosh
The Symbolic, Mechanized, Observable, Operational SHell: an executable formalization of the POSIX shell standard.
Stars: ✭ 86 (-28.33%)
Mutual labels:  shell-scripting
ubuntu-2004
🔵 Curso GRÁTIS de GNU/Linux Ubuntu Server 20.04.x LTS - DevOps utilizando Shell Script
Stars: ✭ 70 (-41.67%)
Mutual labels:  shell-scripting
furipota
(unmaintained) A discrete FRP DSL for describing better build pipelines.
Stars: ✭ 22 (-81.67%)
Mutual labels:  shell-scripting
HackerRank-LinuxShell
HackerRank-LinuxShell Solutions 💻
Stars: ✭ 26 (-78.33%)
Mutual labels:  shell-scripting
datatools
A set of tools for working with JSON, CSV and Excel workbooks
Stars: ✭ 68 (-43.33%)
Mutual labels:  shell-scripting
BashConfig
BASH configuration files.
Stars: ✭ 46 (-61.67%)
Mutual labels:  shell-scripting
AutoBrew
AutoBrew: Homebrew deployments made easy
Stars: ✭ 71 (-40.83%)
Mutual labels:  shell-scripting
ejson2env
Decrypt EJSON secrets and export them as environment variables.
Stars: ✭ 44 (-63.33%)
Mutual labels:  shell-scripting
ubuntu-1804
🔵 Curso GRÁTIS Linux Ubuntu Server 18.04.x LTS - REPOSITÓRIO CONGELADO - Esse repositório não irá mais receber atualizações. Novo repositório: vaamonde/ubuntu-2004
Stars: ✭ 99 (-17.5%)
Mutual labels:  shell-scripting
vonuvoli-scheme
vonuvoli Scheme -- an R7RS interpreter written in Rust focused on systems programming and scripting (i.e. processes, file-system, etc.) with performance and safety in mind
Stars: ✭ 81 (-32.5%)
Mutual labels:  shell-scripting
fabula
Minimalist server scripts.
Stars: ✭ 53 (-55.83%)
Mutual labels:  shell-scripting
vastringify
Type-safe Printf in C
Stars: ✭ 60 (-50%)
Mutual labels:  string-escape

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].