Archived
1
0
Fork 0
This repository has been archived on 2025-03-10. You can view files and clone it, but cannot push or open issues or pull requests.
shbot/shquote.sh

26 lines
630 B
Bash
Raw Normal View History

2009-08-19 12:22:40 +02:00
#!/bin/bash
if [ -n "$2" ]; then
ARGS=$* && ARGS=($ARGS)
OWNER=$1
LEN=`expr ${#ARGS[*]}`
QUOTE=${ARGS[@]:1:$LEN}
echo "${OWNER}" >> shquote.txt
echo "${QUOTE}" >> shquote.txt
#elif [ -n "$1" ]; then
# TODO : quote someone
else
NB_LINES=(`wc -l shquote.txt`)
LINE=$((RANDOM * NB_LINES[0] / 65534))
# IFS="\r" LINES=(`tail -n $((LINE + 2)) shquote.txt | head -n 2`)
# QUOTE=${LINES[0]}
# OWNER=${LINES[1]}
QUOTE=`tail -n $((LINE * 2 + 1)) shquote.txt | head -n 1`
OWNER=`tail -n $((LINE * 2 + 2)) shquote.txt | head -n 1`
echo "\"${QUOTE}\""
echo "-- ${OWNER}"
fi