moreutils-go

Go rewrite of moreutils.

GPL-3.0 License

Stars
0

moreutils-go

A Go rewrite of moreutils: A collection of the Unix tools that nobody thought to write long ago when Unix was young.

Some of the original moreutils commands require Perl, so I decided to rewrite them in a language which can compile into a single binary with no dependencies.

Applets

  • chronic: Runs a command quietly unless it fails
  • combine: Combine sets of lines from two files using boolean operations
  • errno: Look up errno names and descriptions
  • ifdata: Get network interface info without parsing ifconfig output
  • ifne: Run a command if the standard input is not empty
  • isutf8: Check whether files are valid UTF-8
  • mispipe: Pipe two commands, returning the exit status of the first
  • parallel: Run multiple jobs at once
  • pee: Tee standard input to pipes
  • sponge: Soak up standard input and write to a file
  • ts: Timestamp standard input
  • vidir: Edit a directory in your text editor
  • vipe: Insert a text editor into a pipe
  • zrun: Automatically decompress arguments to command

Installation

APT (Ubuntu, Debian)

  1. If you don't have it already, install the ca-certificates package

    sudo apt install ca-certificates
    
  2. Add gabe565 apt repository

    echo 'deb [trusted=yes] https://apt.gabe565.com /' | sudo tee /etc/apt/sources.list.d/gabe565.list
    
  3. Update apt repositories

    sudo apt update
    
  4. Install moreutils-go

    sudo apt install moreutils-go
    

RPM (CentOS, RHEL)

  1. If you don't have it already, install the ca-certificates package

    sudo dnf install ca-certificates
    
  2. Add gabe565 rpm repository to /etc/yum.repos.d/gabe565.repo

    [gabe565]
    name=gabe565
    baseurl=https://rpm.gabe565.com
    enabled=1
    gpgcheck=0
    
  3. Install moreutils-go

    sudo dnf install moreutils-go
    

AUR (Arch Linux)

Install moreutils-go-bin with your AUR helper of choice.

Homebrew (macOS, Linux)

Install moreutils-go from gabe565/homebrew-tap:

brew install gabe565/tap/moreutils-go

GitHub Actions

This repository can be added to a GitHub Actions workflow to install the applets.

Example

name: Example

on: push

jobs:
  example:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: gabe565/moreutils-go@v0
      - run: echo hello world | ts

Docker

A Docker image is available at ghcr.io/gabe565/moreutils

In this container, all applets are in the root directory.

In a Terminal

Some commands can be run directly from a terminal:

echo hello world | docker run --rm -i ghcr.io/gabe565/moreutils ts

While Building a Container

If you are building a container and need one of the applets, you can copy them directly to your container during build:

FROM alpine
COPY --from=ghcr.io/gabe565/moreutils:0 /usr/bin/ts /usr/bin
CMD echo hello world | ts

Manual Installation

  1. Download and run the latest release binary for your system and architecture.
  2. Extract the binary and place it in the desired directory.
  3. Run moreutils install -sr DIRECTORY to generate symlinks for each command.

Differences

My goal is 100% compatability, but there are currently some differences compared to moreutils:

Applet Differences
errno The original implementation prints some errors which are not used by the current OS. For example, code 35 could match EAGAIN and EWOULDBLOCK. Most operating systems only use one or the other, so this implementation does not print duplicates.
ifdata The rewrite supports the -ph and -pf flags on all operating systems, and all statistics flags on Linux and Darwin.
isutf8 Unlike moreutils, which prints the expected value range for non-UTF-8 files, the rewrite only logs the offending line, byte, and char.
lckdo Deprecated in moreutils and intentionally not implemented here. It is recommended to use flock as a replacement.
parallel Parallel is not symlinked by default since GNU Parallel is typically preferred.
ts The -m flag does not affect functionality since Go always uses the system's monotonic clock.
Package Rankings
Top 6.32% on Proxy.golang.org
Badges
Extracted from project README's
GitHub release (latest by date) Build Go Report Card