diff --git a/README.md b/README.md index 1ecf00d..4e12c9e 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ You can also make "beautiful" ASCII patterns -#--#--#--#--#--#--#--#--#--#--#-- -That's it, no requirements, just pure old `bash` and `tput`, check the source, +That's it, no requirements, just pure old POSIX shell and `tput`, check the source, it's free. ## More diff --git a/hr b/hr index 9021f13..56066f8 100755 --- a/hr +++ b/hr @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # The MIT License (MIT) # @@ -22,30 +22,23 @@ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. COLS="$(tput cols)" -if (( COLS <= 0 )) ; then +if [ "$COLS" -le 0 ] ; then COLS="${COLUMNS:-80}" fi hr() { - local WORD="$1" - local LINE='' - - if [[ -z "$WORD" ]] ; then - return; + if [ -z "$1" ] ; then + return fi - printf -v LINE '%*s' "$COLS" - LINE="${LINE// /${WORD}}" - echo "${LINE:0:${COLS}}" + printf '%*s' "$COLS" ' ' | sed "s/ /$1/g" | grep -o "^.\{$COLS\}" } hrs() { - local WORD - for WORD in "${@:-#}" do hr "$WORD" done } -[ "$0" == "$BASH_SOURCE" ] && hrs "$@" +hrs "$@"