summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-12-06 13:12:52 -0500
committerJakob Kaivo <jkk@ung.org>2019-12-06 13:12:52 -0500
commitea8dcfa1cdbc1eeb26880039a8825fc2e066fb0c (patch)
tree8a2ccec1f4ddd032ba53dcd4d1f6d48dc02f80ed
parent8a03b53126ef4ba6536718ef9487090cc10a7ca1 (diff)
translate all characters on command lineHEADmaster
-rw-r--r--ord.sh13
1 files changed, 11 insertions, 2 deletions
diff --git a/ord.sh b/ord.sh
index fac6b09..8cca7e6 100644
--- a/ord.sh
+++ b/ord.sh
@@ -9,7 +9,7 @@ done
shift $((OPTIND - 1))
-if [ $# -ne 1 ] || [ ${#1} -ne 1 ]; then
+if [ $# -eq 0 ]; then
printf 'usage: %s [-d|-x|-o] char\n' "$0"
printf '\t-d print number in decimal (default)\n'
printf '\t-x print number in hexadecimal\n'
@@ -17,4 +17,13 @@ if [ $# -ne 1 ] || [ ${#1} -ne 1 ]; then
exit 1
fi
-printf "%${format}\n" "\"$1\""
+string="$@"
+while [ ${#string} -gt 0 ]; do
+ printf "%${format}" "\"${string}\""
+ string=${string#?}
+ if [ ${#string} -gt 0 ]; then
+ printf ' '
+ else
+ printf '\n'
+ fi
+done