My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
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
# ----------------------------------------------------------------------------
# http://catb.org/jargon/
# Dicionário de jargões de informática, em inglês.
# Uso: zzdicjargon palavra(s)
# Ex.: zzdicjargon vi
# zzdicjargon all your base are belong to us
#
# Autor: Aurelio Marinho Jargas, www.aurelio.net
# Desde: 2000-02-22
# Licença: GPL
# ----------------------------------------------------------------------------
zzdicjargon ()
{
zzzz -h dicjargon "$1" && return

local achei achei2 num mais
local url='http://catb.org/jargon/html'
local cache="$ZZTMP.jargonfile"
local padrao=$(echo "$*" | sed 's/ /-/g')

# Verificação dos parâmetros
[ "$1" ] || { zztool uso dicjargon; return 1; }

# Se o cache está vazio, baixa listagem da Internet
if ! test -s "$cache"
then
$ZZWWWLIST "$url/go01.html" |
sed '
/^ *[0-9][0-9]*\. /!d
s@.*/html/@@
/^[A-Z0]\//!d' > "$cache"
fi

achei=$(grep -i "$padrao" $cache)
num=$(echo "$achei" | sed -n '$=')

[ "$achei" ] || return

if [ $num -gt 1 ]
then
mais=$achei
achei2=$(echo "$achei" | grep -w "$padrao" | sed 1q)
[ "$achei2" ] && achei="$achei2" && num=1
fi

if [ $num -eq 1 ]
then
$ZZWWWDUMP -width=72 "$url/$achei" |
sed '1,/_\{9\}/d;/_\{9\}/,$d'
[ "$mais" ] && zztool eco '\nTermos parecidos:'
else
zztool eco 'Achei mais de um! Escolha qual vai querer:'
fi

[ "$mais" ] && echo "$mais" | sed 's/..// ; s/\.html$//'
}

Change log

r710 by aureliojargas on Mar 29, 2012   Diff
SEGURANÇA: $1 colocado entre aspas na
chamada padrão zzzz -h de todas as
funções.
Go to: 
Sign in to write a code review

Older revisions

r668 by aureliojargas on Mar 28, 2012   Diff
lint: removendo espaços inúteis.
r655 by aureliojargas on Mar 23, 2012   Diff
s/Aurélio/Aurelio/ *
r524 by aureliojargas on May 23, 2011   Diff
COMBO: Agora todas as chamadas ao
zztool uso por falha na verificação
dos parâmetros possuem um return 1
depois. Assim outros scripts que usam
as funções podem detectar erros.
All revisions of this file

File info

Size: 1428 bytes, 56 lines
Powered by Google Project Hosting