aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2022-08-13 09:40:52 -0300
committerEuAndreh <eu@euandre.org>2022-08-13 09:40:52 -0300
commit5f8d2e81350c326b31be12731e120efbbd6e9c16 (patch)
treecdc16e945e9b4b8703f4d71051fdcbb8952a6d83 /bin
parentbin/git-cleanup: Add working utility (diff)
downloaddotfiles-5f8d2e81350c326b31be12731e120efbbd6e9c16.tar.gz
dotfiles-5f8d2e81350c326b31be12731e120efbbd6e9c16.tar.xz
bin/{uc,lc}: Add working utilities
Diffstat (limited to 'bin')
-rwxr-xr-xbin/lc70
-rwxr-xr-xbin/uc70
2 files changed, 140 insertions, 0 deletions
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:]'
diff --git a/bin/uc b/bin/uc
new file mode 100755
index 0000000..e8bd9fb
--- /dev/null
+++ b/bin/uc
@@ -0,0 +1,70 @@
+#!/bin/sh
+set -eu
+
+usage() {
+ cat <<-'EOF'
+ Usage:
+ uc
+ uc -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 [:lower:] [:upper:]'.
+
+
+ Examples:
+
+ Normalize to lower-case:
+
+ $ echo EuAndreh | uc
+ EUANDREH
+
+
+ Keep the text as-is:
+
+ $ echo ANDREH | uc
+ 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 '[:lower:]' '[:upper:]'