Created
October 31, 2020 21:45
-
-
Save h8rt3rmin8r/0e7b8a191947c76ec5ec90dc6b9577b4 to your computer and use it in GitHub Desktop.
Print an eighty-character line to the terminal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
#>------------------------------------------------------------------------------ | |
#> | |
#> [ print-line ] | |
#> | |
#> Print an eighty-character line to the terminal. | |
#> | |
#> No inputs are required when invoking this script. | |
#> | |
#> Printed lines will default to being constructed with dashes (-) but can | |
#> be customized by passing a desired character as an input. | |
#> | |
#> USAGE: | |
#> | |
#> ./print-line.sh <INPUT> | |
#> ./print-line.sh <OPTION> | |
#> | |
#> where "INPUT" is some optional input character; and where "OPTION" is an | |
#> optional parameter of the following: | |
#> | |
#> | | |
#> -h, --help | Print this help text to the terminal | |
#> | | |
#> | |
#> ATTRIBUTION: | |
#> | |
#> Created on 20201031 by h8rt3rmin8r ([email protected]) | |
#> | |
#> Source: | |
#> https://gist.github.com/h8rt3rmin8r/0e7b8a191947c76ec5ec90dc6b9577b4 | |
#> | |
#>------------------------------------------------------------------------------ | |
function _help() { | |
cat "${0}" \ | |
| grep -E '^#[>]' \ | |
| sed 's/^..//' | |
return $? | |
} | |
function _run() { | |
printf "%080d\n" 0 \ | |
| tr '0' "${_x}" | |
return $? | |
} | |
_x="-" | |
if [[ "${1}" =~ ^[-][hH]$ || "${1}" =~ ^[-]+help$ ]]; then | |
_help | |
else | |
if [[ ! "x${1}" == "x" ]]; then | |
_x="${1:0:1}" | |
fi | |
_run | |
fi | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment