nix-conf/user/bin/sm

25 lines
320 B
Plaintext
Raw Normal View History

2024-11-08 01:11:23 -05:00
#!/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 "$2 is not a valid number" >&2; exit 2 ;;
esac
i=0
while [ $i -lt $1 ]; do
printf "%s" "$s"
: $((i += 1))
done