Dependency-free replacement for GNU parallel, perfect fit for usage in an initramfs.

Related tags

Command Line coshell
Overview

coshell v0.2.5

A no-frills dependency-free replacement for GNU parallel, perfect for initramfs usage.

Licensed under GNU/GPL v2.

How it works

An sh -c ... command is started for each of the input commands; environment and current working directory are preserved. NOTE: file descriptors are not

All commands will be executed, no matter which one fails. Return value will be the sum of exit values of each command.

It is suggested to use exec if you want the shell-spawned process to substitute each of the wrapping shells and be able to handle signals. See also http://tldp.org/LDP/abs/html/process-sub.html Alternatively, you can use --shell="" to force the usage of no shell (see description in the options section).

Self-contained

$ ldd coshell
	not a dynamic executable

Thanks to Go language, this is a self-contained executable thus a perfect match for inclusion in an initramfs or any other project where you would prefer not to have too many dependencies.

Installation

Once you run:

go get github.com/gdm85/coshell

The binary will be available in your $GOPATH/bin; alternatively, build it with:

make

Then copy the output bin/coshell binary to your $PATH, ~/bin, /usr/local/bin or any of your option.

Usage

Specify each command on a single line as standard input.

Example:

echo -e "echo test1\necho test2\necho test3" | coshell

Output:

test3
test1
test2

sequence length option

By specifying a sequence length greater than 1 it is possible to group commands in sequences. Each group of commands will be executed sequentially.

deinterlace option

Order is not deterministic by default, but with option --deinterlace or -d all output will be buffered and afterwards printed in the same chronological order as your input.

shell

It is possible to specify a custom shell prefix or no shell at all (--shell=""); in such case, commands will be split according to /bin/sh's word-splitting rules. It supports backslash-escapes, single-quotes, and double-quotes. Notably it does not support the $'' style of quoting. It also doesn't attempt to perform any other sort of expansion, including brace expansion, shell expansion, or pathname expansion.

If the given input has an unterminated quoted string or ends in a backslash-escape an error is returned.

halt-all option

If --halt-all or -a option is specified then first process to terminate unsuccessfully (with non-zero exit code) will cause all processes to immediately exit (including coshell) with the exit code of such process.

master option

The --master=n or -m=n option takes a positive integer number as the index of specified command lines to identify which process "leads" the pack: when the process exits all neighbour processes will be terminated as well and its exit code will be adopted as coshell exit code.

Examples

See examples/ directory for examples of various use-cases.

Issues
  • Created support for substitution

    Created support for substitution

    Hey, if you're interested I've added basic support for doing this:

    echo -e "a\nb\nc" | go run coshell.go -p "echo ?{#} : ?{}" -e "?"
    0 : a
    1 : b
    2 : c
    

    Y'know, cause parallel can do that, though noisily.

    opened by CreativeCactus 7
  • make doesn't work

    make doesn't work

    Running make I find:

    ~/p/coshell ❯❯❯ make
    mkdir -p bin/
    ./emu-gopath.sh github.com/gdm85/coshell 'GOBIN="bin/" go install'
    cannot install, GOBIN must be an absolute path
    

    I tried editing that line to the following, which seemed to fix it (I can make this a pull request, but it seems very simple, and I don't know go well enough to be sure this is what I should do).

    ./emu-gopath.sh github.com/gdm85/coshell 'GOBIN="`pwd`/bin/" go install'
    
    opened by ChrisJefferson 1
  • Cannot find cosh package with current package import

    Cannot find cosh package with current package import

    *Edit: The new non-relative path update caused an error. But it was just cause the application where i used it was not having the coshell package installed in the $GOPATH. Sorry for this first issue being a non-issue. :(

    opened by rvzanten 1
Owner
gdm85
gdm85
M3u8-parallel-downloader - M3u8 parallel downloader with golang

m3u8-parallel-downloader Usage ./m3u8-parallel-downloader -input http://example.

CzBiX 3 Feb 5, 2022
A Simple and Clear CLI library. Dependency free.

A Simple and Clear CLI library. Dependency free. Features Nested Subcommands Uses the standard library flag package Auto-generated help Custom banners

Lea Anthony 105 May 5, 2022
Dependency-Free Bencode Editor

rbEdit A statically compiled and dependency-free Bencode editor in Go, useful for command line use and scripts. Quick Start # Compile for linux arch:

Jari Sundell 10 Apr 30, 2022
Readline is a pure go(golang) implementation for GNU-Readline kind library

A powerful readline library in Linux macOS Windows Solaris Guide Demo Shortcut Repos using readline Feedback If you have any questions, please submit

chzyer 1.8k May 20, 2022
GNU coreutils remade in Go for RosetteOS

Rosebush GNU and POSIX coreutils remade in Go for RosetteOS Build To compile the Rosebush, simply make -B This will compile all the utils one by one.

RosetteOS Linux 5 Oct 4, 2021
GDScript Syntax Highlighting in GNU Nano

nano-gdscript GDScript Syntax Highlighting in GNU Nano. Updated regularly every minor updates. Contributions are welcomed Installation This is 100% fr

null 0 Jun 25, 2021
A Go implementation of gnu-coreutils programs

Go-Coreutils A Go implementation of gnu-coreutils programs (https://www.gnu.org/software/coreutils/manual/coreutils.html) Build and Run In the root di

Will Cygan 0 Jan 15, 2022
A parallel downloader with resume capability

Grozilla The Grozilla is a simple implementation that allows downloading of video,audio,package or zip files parallely and efficiently using light wei

Prashant Agarwala 39 May 5, 2022
Stack Up is a simple deployment tool that performs given set of commands on multiple hosts in parallel.

Stack Up is a simple deployment tool that performs given set of commands on multiple hosts in parallel. It reads Supfile, a YAML configuration file, which defines networks (groups of hosts), commands and targets.

Pressly Inc. 2.3k May 14, 2022
Simple Todo List - Wunderlist Replacement

DoIT Todo List This is a simple todo-list made with Vue(frontend) and a simple webserver written in Go(backend). Note that this started out as a simpl

Magnus 74 Jan 16, 2022
A lightweight replacement for the standard fmt package, reduces binary size by roughly 400kb in a hello world

console This is a lightweight replacement for the fmt package, reduces the binary size by roughly 400kb in a hello world program. Please note: This pa

null 1 Nov 7, 2021
Disk usage analyzer with console interface written in Go

Gdu is intended primarily for SSD disks where it can fully utilize parallel processing. However HDDs work as well, but the performance gain is not so huge.

Daniel Milde 1.8k May 9, 2022
Integrated console application library, using Go structs as commands, with menus, completions, hints, history, Vim mode, $EDITOR usage, and more ...

Gonsole - Integrated Console Application library This package rests on a readline console library, (giving advanced completion, hint, input and histor

null 17 Apr 3, 2022
Redis inventory is a tool to analyse Redis memory usage by key patterns and displaying it hierarchically

Redis inventory is a tool to analyse Redis memory usage by key patterns and displaying it hierarchically. The name is inspired by "Disk Inventory X" tool doing similar analysis for disk usage.

Aleks Obukhov 175 May 1, 2022
A cli that shows a GitHub-like language usage statistics bar.

barley A cli that shows a GitHub-like language usage statistics bar. barley analyses the programming languages used in a directory and creates a used

Barış İnandıoğlu 3 Jan 8, 2022
Basic usage of Vecty framework examples.

vecty-examples Basic usage of Vecty framework examples. Instructions Change directory to the folder with the example you wish to run Run wasmserve. To

Patricio Whittingslow 0 Jan 10, 2022
Just a simple CLI tool to group dependabot PRs by dependency and merge them.

Dependabotbot Have you been the victim of a lodash update? Has your notification page in Github been assaulted by needing to update a patch version of

Chris Griffing 19 Apr 11, 2022
word2text - a tool is to convert word documents (DocX) to text on the CLI with zero dependencies for free

This tool is to convert word documents (DocX) to text on the CLI with zero dependencies for free. This tool has been tested on: - Linux 32bit and 64 bit - Windows 32 bit and 64 bit - OpenBSD 64 bit

Ryan Thomas 5 Apr 19, 2021
a Go language free and open-source document for learning from zero level

Go document a GO language free and open-source document for learning from zero level Please publish and collaborate OPEN-SOURCE Sections About go lang

Erfan Hanifezade 16 May 9, 2022