-
Notifications
You must be signed in to change notification settings - Fork 3
/
dick.sh
executable file
·118 lines (98 loc) · 2.28 KB
/
dick.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
VERSION='0.2.0'
is_numeric() {
echo "$1" | grep -E "^[0-9]+$"
}
dick_usage() {
echo "
Usage: dick [<length>] [options]
Options:
-l, --length [<length>] Set dick length, in characters. Default is 5, a
moderate dick length. It must be an integer,
positive number (some dignity applies).
-s, --sperm [<length>] Display sperm stream with given <length>, in
characters. Default is 3. Omit this option or set
it to 0 to output no sperm at all.
-n Do not echo trailing newline.
-v, --version Display dick version.
-h, --help Display this help information.
"
}
LENGTH=5
SPERM=0
LAST_OPT="-l"
NEW_LINE=1
while [ "$1" != "" ]; do
OPT=`printf '%q' "$1" | awk -F= '{print $1}'`
VAL=`printf '%q' "$1" | awk -F= '{print $2}'`
case $OPT in
-h | --help)
dick_usage
exit
;;
-v | --version)
echo "dick $VERSION"
exit
;;
-n)
NEW_LINE=""
;;
-s | --sperm)
if [[ "$VAL" == "" ]]; then
SPERM=3
LAST_OPT="-s"
else
SPERM=$VAL
fi
;;
-l | --length)
if [[ "$VAL" == "" ]]; then
LAST_OPT="-l"
else
LENGTH=$VAL
fi
;;
*)
case $LAST_OPT in
-s)
SPERM=$OPT
;;
-l)
LENGTH=$OPT
;;
*)
printf "Unexpected argument: '%q'\n" "$OPT"
dick_usage
exit 1
;;
esac
LAST_OPT=""
esac
shift
done
LENGTH_IS_NUMERIC=`is_numeric $LENGTH`
if [[ $LENGTH_IS_NUMERIC != "" ]]; then
if [[ "$LENGTH" -lt 1 ]]; then
echo "Underestimated 'length' argument"
dick_usage
exit 1
fi
else
echo "Bad 'length' argument: $LENGTH is not an integer, positive number"
dick_usage
exit 1
fi
SPERM_IS_NUMERIC=`is_numeric $SPERM`
if [[ $SPERM_IS_NUMERIC == "" ]]; then
echo "Bad 'sperm' length: $SPERM is not an integer, positive number"
dick_usage
exit 1
fi
DICK="8`seq 1 $LENGTH | sed 's/.*/=/' | tr -d '\n'`D"
if [[ $SPERM != "0" ]]; then
DICK="$DICK `seq 1 $SPERM | sed 's/.*/~/' | tr -d '\n'`"
fi
echo -n "$DICK"
if [[ $NEW_LINE != "" ]]; then
echo
fi