From c09d91fe95fca4367f47c06fc808cd02a1a8e6a5 Mon Sep 17 00:00:00 2001 From: Ben Burwell Date: Tue, 13 Aug 2019 14:40:54 -0400 Subject: add bins --- templates/.bin/rot13 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 templates/.bin/rot13 (limited to 'templates/.bin/rot13') diff --git a/templates/.bin/rot13 b/templates/.bin/rot13 new file mode 100755 index 0000000..c72f41e --- /dev/null +++ b/templates/.bin/rot13 @@ -0,0 +1,18 @@ +#!/bin/sh + +offset=${1:-13} + +if [ "$offset" -lt 1 ]; then + echo "offset must be greater than zero" >&2 + exit 1 +elif [ "$offset" -gt 25 ]; then + echo "offset must be less than 26" >&2 + exit 1 +fi + +alphabet=aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ +sub1=$(echo "$alphabet" | cut -c $((offset * 2 + 1))-) +sub2=$(echo "$alphabet" | cut -c 1-$((offset * 2))) +sub=$sub1$sub2 + +tr "$alphabet" "$sub" -- cgit v1.2.3