Skip to content

Commit e1e6b19

Browse files
txgkLuRsT
authored andcommitted
make script posix compliant
1 parent f5d2f5b commit e1e6b19

2 files changed

Lines changed: 7 additions & 14 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ You can also make "beautiful" ASCII patterns
5757
-#--#--#--#--#--#--#--#--#--#--#--
5858

5959

60-
That's it, no requirements, just pure old `bash` and `tput`, check the source,
60+
That's it, no requirements, just pure old POSIX shell and `tput`, check the source,
6161
it's free.
6262

6363
## More

hr

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/sh
22

33
# The MIT License (MIT)
44
#
@@ -22,30 +22,23 @@
2222
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2323

2424
COLS="$(tput cols)"
25-
if (( COLS <= 0 )) ; then
25+
if [ "$COLS" -le 0 ] ; then
2626
COLS="${COLUMNS:-80}"
2727
fi
2828

2929
hr() {
30-
local WORD="$1"
31-
local LINE=''
32-
33-
if [[ -z "$WORD" ]] ; then
34-
return;
30+
if [ -z "$1" ] ; then
31+
return
3532
fi
3633

37-
printf -v LINE '%*s' "$COLS"
38-
LINE="${LINE// /${WORD}}"
39-
echo "${LINE:0:${COLS}}"
34+
printf '%*s' "$COLS" ' ' | sed "s/ /$1/g" | grep -o "^.\{$COLS\}"
4035
}
4136

4237
hrs() {
43-
local WORD
44-
4538
for WORD in "${@:-#}"
4639
do
4740
hr "$WORD"
4841
done
4942
}
5043

51-
[ "$0" == "$BASH_SOURCE" ] && hrs "$@"
44+
hrs "$@"

0 commit comments

Comments
 (0)