-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbash.bmod
80 lines (69 loc) · 1.81 KB
/
bash.bmod
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
#!/usr/bin/env bash
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2, June 1991.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/gpl-2.0.html>,
# or in pdf format at <http://www.dhampir.no/stuff/private/gpl-2.0.pdf>
# Copyright 2013 - Øyvind 'bolt' Hvidsten <[email protected]>
! ${GHOST:-false} || return 0
if [[ -z "${bash_file:-}" ]]; then
sf_mkfile -qo "bash_file"
fi
function bash_do
{
if ! type lynx >/dev/null 2>&1; then
reply "error - lynx was not found"
return
fi
local url="http://www.bash.org/?"
if [[ -z "${@:-}" ]]; then
url+="random1"
elif sf_integer "$@"; then
url+="$*"
else
url+="search=$(sf_urlencode "$*")"
fi
if
! lynx -dump -nolist -nomargins -width=1024 "$url" >"$bash_file" 2>/dev/null ||
sf_isemptyfile "$bash_file"
then
reply "error - no output"
fi
local oldtx=$TXCOUNT
local line printing=false
while read -r line; do
read -r line <<<"$line"
case "$line" in
'') ;;
'#'*' +('*')- [X]')
$printing || { printing=true; continue; }
;&
'Search '*'Sort by:'*|\
'Home / Latest / Browse / Random'*)
! $printing || break
;;
*)
if $printing; then
say "$reply" "$line"
sleep 0.5
fi
;;
esac
done <"$bash_file"
if ((oldtx == TXCOUNT )); then
reply "no result"
fi
}
if [[ -n "$reply" ]] && [[ "${data_larray[0]}" = "bash" ]]; then
if (( data_count == 1 )); then
bash_do
else
bash_do "$(dfromi 1)"
fi
fi