Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 35 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
SHELL := /usr/bin/env sh
TESTS := $(wildcard tests/*.sh)

INSTALL ?= install
PREFIX ?= /usr/local
BASH_COMP_DIR := $(shell pkg-config --variable=completionsdir bash-completion 2>/dev/null)
ifeq ($(BASH_COMP_DIR),)
BASH_COMP_DIR = /usr/share/bash-completion/completions
endif
ZSH_COMP_DIR ?= $(PREFIX)/share/zsh/site-functions
MANDIR ?= $(PREFIX)/share/man
MAN1DIR = $(MANDIR)/man1

.PHONY: clean install test uninstall
.PHONY: all clean info install install-inline-checksum install-inline-checksum-docs test uninstall

default: all

all: info

clean:
ifneq ($(wildcard tests/*.log),)
@printf "Cleaning up test logs.\n"
@$(RM) tests/*.log
else
@printf "Nothing to clean.\n"
@printf "No test logs to clean.\n"
endif
ifneq ($(wildcard docs/*.1.gz),)
@printf "Cleaning up man pages.\n"
@$(RM) docs/*.1.gz
else
@printf "No man pages to clean.\n"
endif

test:
Expand All @@ -32,14 +45,30 @@ test:
done; \
[ "$$FAILURE" -eq 0 ] || exit 1

install:
info:
@help2man ./inline-checksum -o docs/inline-checksum.1
@gzip docs/inline-checksum.1

install: install-inline-checksum install-inline-checksum-info

install-inline-checksum:
@printf "Installing inline-checksum to %s/bin...\n" $(DESTDIR)$(PREFIX)
@install -Dm 755 inline-checksum $(DESTDIR)$(PREFIX)/bin/inline-checksum
@install -Dm 644 inline-checksum-completion $(DESTDIR)$(BASH_COMP_DIR)/inline-checksum
@install -Dm 644 inline-checksum-completion $(DESTDIR)$(ZSH_COMP_DIR)/_inline-checksum
@$(INSTALL) -Dm 755 inline-checksum $(DESTDIR)$(PREFIX)/bin/inline-checksum

install-inline-checksum-info: info
@printf "Installing inline-checksum bash completion to %s...\n" $(DESTDIR)$(BASH_COMP_DIR)
@$(INSTALL) -Dm 644 docs/inline-checksum-completion $(DESTDIR)$(BASH_COMP_DIR)/inline-checksum
@printf "Installing inline-checksum zsh completion to %s...\n" $(DESTDIR)$(ZSH_COMP_DIR)
@$(INSTALL) -Dm 644 docs/inline-checksum-completion $(DESTDIR)$(ZSH_COMP_DIR)/_inline-checksum
@printf "Installing inline-checksum man page to %s...\n" $(DESTDIR)$(MAN1DIR)
@$(INSTALL) -Dm 644 docs/inline-checksum.1.gz $(DESTDIR)$(MAN1DIR)/inline-checksum.1.gz
-@mandb > /dev/null 2>&1

uninstall:
@printf "Uninstalling inline-checksum from %s/bin...\n" $(DESTDIR)$(PREFIX)
@printf "Uninstalling inline-checksum documentation from %s...\n" $(DESTDIR)$(PREFIX)
@$(RM) $(DESTDIR)$(PREFIX)/bin/inline-checksum
@$(RM) $(DESTDIR)$(BASH_COMP_DIR)/inline-checksum
@$(RM) $(DESTDIR)$(ZSH_COMP_DIR)/_inline-checksum
@$(RM) $(DESTDIR)$(MAN1DIR)/inline-checksum.1.gz
-@mandb > /dev/null 2>&1
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ After running the test suite, you can clean up the generated log files with `mak
Assuming a site provides it, a checksum can be used to verify a downloaded script before running it as follows:

```sh
curl -fsSL <url> | inline-checksum [--algorithm[=| ]<sha256|sha512|md5>] <checksum> | sh -
curl -fsSL <url> | inline-checksum [--algorithm[=| ]<sha256|sha512|md5>] <checksum> [| sh -]
```

Alternatively, a local file can have its checksum validated as follows:

```sh
inline-checksum [--algorithm[=| ]<sha256|sha512|md5>] <checksum> <file>
inline-checksum [--algorithm[=| ]<sha256|sha512|md5>] <checksum> <file> [| sh -]
```

# Uninstallation
Expand Down
File renamed without changes.
Binary file added docs/inline-checksum.1.gz
Binary file not shown.
21 changes: 11 additions & 10 deletions inline-checksum
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# ------------------------------------- #

_program_name="$(basename "${0}")"
_version="1.1.2"
_version="1.2.0"

usage() {
cat <<-EOF
Expand All @@ -64,26 +64,27 @@ usage() {
Usage: ${_program_name} [-h|V] | [-x] [-a[=| ]<ALGORITHM>] <CHECKSUM> [TARGET_FILE]

Options:
-h, --help Show this help message and exit.
-V, --version Show version information and exit.
-a, --algorithm <ALGORITHM> The algorithm used to compute the checksum. Accepts one of 'sha256', 'sha512', or 'md5'. Defaults to 'sha256' if unspecified.
-x, --output-filename Output filename when piping, instead of file contents. The caller is responsible for cleaning up any resulting temporary files.
-- Stop processing command line arguments.
-h, --help Show this help message and exit.
-V, --version Show version information and exit.
-a, --algorithm <ALGORITHM> The algorithm used to compute the checksum. Accepts one of 'sha256', 'sha512', or 'md5'. Defaults to 'sha256' if unspecified.
-x, --output-filename Output filename when piping, instead of file contents. The caller is responsible for cleaning up any resulting temporary files.
-- Stop processing command line arguments.

Positional Arguments:
<CHECKSUM> The checksum against which to compare.
[TARGET_FILE] The file to compute a checksum for. If absent or '-', reads input from stdin.
<CHECKSUM> The checksum against which to compare.
[TARGET_FILE] The file to compute a checksum for. If absent or '-', reads input from stdin.

Examples:
curl -fsSL <url> | inline-checksum [-x] [--algorithm[=| ]<sha256|sha512|md5>] <checksum> | sh -
curl -fsSL <url> | inline-checksum [-x] [--algorithm[=| ]<sha256|sha512|md5>] <checksum> [| sh -]

inline-checksum [-x] [--algorithm[=| ]<sha256|sha512|md5>] <checksum> <file> [| sh -]
EOF
}

version() {
cat <<-EOF
Inline-Checksum ${_version}
Copyright © 2026 Josh Beale <jbeale2023@gmail.com>.
Copyright (C) 2026 Josh Beale <jbeale2023@gmail.com>.
Licence MIT: <https://directory.fsf.org/wiki/License:Expat>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Expand Down