Lines 15-20
Link Here
|
15 |
echo "Usage: $0 [-L language] [-x charset] [-r] [-q] [<directory|file>]" >&2 |
15 |
echo "Usage: $0 [-L language] [-x charset] [-r] [-q] [<directory|file>]" >&2 |
16 |
echo " -L and -x take parameters just as enca(1)" >&2 |
16 |
echo " -L and -x take parameters just as enca(1)" >&2 |
17 |
echo " -r turns on recursion" >&2 |
17 |
echo " -r turns on recursion" >&2 |
|
|
18 |
echo " -t ascii transliteration (via lynx)" >&2 |
18 |
echo " -q means quiet" >&2 |
19 |
echo " -q means quiet" >&2 |
19 |
exit 1 |
20 |
exit 1 |
20 |
} |
21 |
} |
Lines 27-33
Link Here
|
27 |
|
28 |
|
28 |
process() |
29 |
process() |
29 |
{ |
30 |
{ |
30 |
new="$(echo $1 | enca -L "$language" -x "$charmap" || failed="$1")" |
31 |
if [ -z "$translit" ]; then |
|
|
32 |
new="$(echo "$1" | enca -L "$language" -x "$charmap" || failed="$1")" |
33 |
else |
34 |
new="$(echo "$1" | sed 's/</\</g' | lynx -nomargins -width 256 -dump -stdin -display_charset=us-ascii -assume_charset="$charmap")" |
35 |
fi |
31 |
[ -z "$new" ] && fatal "$1 results in EMPTY converted name!" |
36 |
[ -z "$new" ] && fatal "$1 results in EMPTY converted name!" |
32 |
[ "$1" != "$new" ] && { |
37 |
[ "$1" != "$new" ] && { |
33 |
[ -e "$new" ] && { |
38 |
[ -e "$new" ] && { |
Lines 49-55
Link Here
|
49 |
|
54 |
|
50 |
### main() |
55 |
### main() |
51 |
|
56 |
|
52 |
TEMP=`getopt -l language:,charset:,recurse,notest,quiet,help -- +L:x:r:N:q:h "$@"` || usage |
57 |
TEMP=`getopt -l language:,charset:,recurse,notest,tranlit,quiet,help -- +L:x:r:N:t:q:h "$@"` || usage |
53 |
eval set -- "$TEMP" |
58 |
eval set -- "$TEMP" |
54 |
eval `locale -k charmap` # $charmap is current charset |
59 |
eval `locale -k charmap` # $charmap is current charset |
55 |
# alas, language code isn't that easy |
60 |
# alas, language code isn't that easy |
Lines 59-64
Link Here
|
59 |
recurse= |
64 |
recurse= |
60 |
wrapper="echo" |
65 |
wrapper="echo" |
61 |
failed= |
66 |
failed= |
|
|
67 |
translit= |
62 |
|
68 |
|
63 |
while :; do |
69 |
while :; do |
64 |
case "$1" in |
70 |
case "$1" in |
Lines 72-77
Link Here
|
72 |
;; |
78 |
;; |
73 |
-N|--notest) wrapper= |
79 |
-N|--notest) wrapper= |
74 |
;; |
80 |
;; |
|
|
81 |
-t|--translit) translit="lynx" |
82 |
;; |
75 |
-q|--quiet) verbose= |
83 |
-q|--quiet) verbose= |
76 |
;; |
84 |
;; |
77 |
-h|--help) usage |
85 |
-h|--help) usage |