/usr/sbin/update-skkdic is in skktools 1.3.3+0.20160513-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 | #!/bin/bash
skkdir=/usr/share/skk
base=SKK-JISYO
suffix=local
file="$skkdir/$base.$suffix"
priority=100
#### print usage and exit.
#### never return
usage ()
{
echo "Usage: $0 [-c] dictionary... (Merge dictionaries)
$0 -d (update-alternatives --remove)
$0 -u (update-alternatives --install)" 1>&2
exit 1
}
#### read a dictionary from stdin, write a cdb-style dictionary to $1.
cdb ()
{
CDB="`which cdb`" || CDB=""
if [[ -z "$CDB" ]]; then
echo "${0##*/}: tinycdb's cdb command not found" >&2
exit 1
fi
tmpf=`tempfile -p skk_ -d "$skkdir"`
trap "if [[ -e "$tmpf" ]]; then rm "$tmpf"; exit 1; fi" EXIT INT TERM
LC_ALL=C awk '
/^[^;]/ {
s = substr($0, index($0, " ") + 1)
print "+" length($1) "," length(s) ":" $1 "->" s
}
END {
print ""
}
' | "$CDB" -c -t $tmpf $1
}
#### merge $* into a dictionary
make_dic ()
{
if [[ $cdb == ".cdb" ]]; then
tailcmd="|$0 __CDB__ $file"
else
tailcmd=">|$file"
fi
bash -c "skkdic-expr `(echo \"$@\" | sed 's/ / + /g' )` | skkdic-sort $tailcmd"
if [[ ! -f $file ]]; then
echo "${0##*/}: cannot create $file" >&2
exit 1
fi
chmod 644 $file
}
#### update-alternatives --install
#### never return
update ()
{
exec update-alternatives --install $skkdir/$base$cdb $base$cdb $file $priority
}
#### MAIN
if [[ $1 == __CDB__ ]]; then # called by myself
cdb $2
exit 0
fi
cdb=""
set -- `getopt cduh "$@"`
for i; do
case "$i" in
-c ) cdb=".cdb"; file=$file$cdb; shift;;
-d ) exec update-alternatives --remove $base$cdb $file;;
-u ) update;;
-h ) usage;;
-- ) shift; break;;
esac
done
if (( $# == 0 )); then
usage
fi
for i; do
if [[ ! -f $i ]]; then
echo "$0: $i: can't open." 1>&2
exit 1
fi
done
if [[ ! -w $skkdir ]]; then
echo "$0: $skkdir: can't write. Are you root?" 1>&2
exit 1
fi
make_dic "$@"
update
|