-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpfunc
More file actions
executable file
·39 lines (31 loc) · 715 Bytes
/
Copy pathpfunc
File metadata and controls
executable file
·39 lines (31 loc) · 715 Bytes
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
#!/bin/bash
if [ -z "$1" ]; then
echo
echo "No function specified"
echo
echo "pfunc command syntax: pfunc <function>"
echo
echo "Example: pfunc func_get_args"
echo
exit 1
else
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
echo
echo "Usage: pfunc <function>"
echo
echo "Example: pfunc strtolower"
echo
exit 1
fi
func=$1
url="http://php.net/$func"
contents=$(lynx -dump $url)
if [[ $contents == *"doesn't exist. Closest matches"* ]]; then
echo
echo >&2 "'$func' is not a valid PHP function"
echo
exit 1
fi
clear
awk -v a="$contents" -v b="$func" 'BEGIN{gsub(/\"\n\"/, "\"\\n\"", a); print substr(a, index(a, b" —"), index(a, "See Also") - index(a, b" —"))}'
fi