nix-conf/user/bin/sm
2025-01-29 23:29:47 -06:00

25 lines
320 B
Bash
Executable file

#!/bin/sh
# string multiply
if [ $# -le 1 ]; then
echo "Usage: ${0##*/} <str> <n>" >&2
exit 1
fi
s="$1"
shift 1
while [ $# -gt 1 ]; do
s="$s $1"
shift 1
done
case $1 in
''|*[!0-9]*) echo "$1 is not a valid number" >&2; exit 2 ;;
esac
i=0
while [ $i -lt $1 ]; do
printf "%s" "$s"
: $((i += 1))
done