From 5f8d2e81350c326b31be12731e120efbbd6e9c16 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sat, 13 Aug 2022 09:40:52 -0300 Subject: bin/{uc,lc}: Add working utilities --- bin/lc | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100755 bin/lc (limited to 'bin/lc') diff --git a/bin/lc b/bin/lc new file mode 100755 index 0000000..111b91b --- /dev/null +++ b/bin/lc @@ -0,0 +1,70 @@ +#!/bin/sh +set -eu + +usage() { + cat <<-'EOF' + Usage: + lc + lc -h + EOF +} + +help() { + cat <<-'EOF' + + Options: + -h, --help show this message + + + Transforms text from STDIN from upper-case to lower-case. It is + the equivalent of running 'tr [:upper:] [:lower:]'. + + + Examples: + + Normalize to lower-case: + + $ echo EuAndreh | lc + euandreh + + + Keep the text as-is: + + $ echo andreh | lc + andreh + EOF +} + + +for flag in "$@"; do + case "$flag" in + --) + break + ;; + --help) + usage + help + exit + ;; + *) + ;; + esac +done + +while getopts 'h' flag; do + case "$flag" in + h) + usage + help + exit + ;; + *) + usage >&2 + exit 2 + ;; + esac +done +shift $((OPTIND - 1)) + + +tr '[:upper:]' '[:lower:]' -- cgit v1.2.3