Skip to content

Instantly share code, notes, and snippets.

@h8rt3rmin8r
Created October 31, 2020 21:45
Show Gist options
  • Save h8rt3rmin8r/0e7b8a191947c76ec5ec90dc6b9577b4 to your computer and use it in GitHub Desktop.
Save h8rt3rmin8r/0e7b8a191947c76ec5ec90dc6b9577b4 to your computer and use it in GitHub Desktop.
Print an eighty-character line to the terminal
#! /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 (161803398@email.tg)
#>
#> 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