Skip to content

Commit 26a67b9

Browse files
committed
Support multi-character hex values.
1 parent 4c61a70 commit 26a67b9

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

bashlib/bashlib

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,8 @@ ord() {
277277
# Outputs the hexadecimal ASCII value of the given character.
278278
#
279279
hex() {
280-
local str=$1 s
281-
for (( s=0; s < ${#str}; ++s )); do
282-
printf '%02X' "'${str:s:1}"
280+
{ (( $# )) && printf %s "$*" || cat; } | while IFS= read -N1; do
281+
printf '%02X ' "'${REPLY}"
283282
done
284283
} # _____________________________________________________________________
285284

0 commit comments

Comments
 (0)