/usr/bin/mewest is in mew-beta-bin 7.0.50~6.7+0.20170719-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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | #!/bin/sh
#
# mewest: Updating indexes of Hyper Estraier
#
# Author: Mitsuo Kuroishi <kuroishi@iij.ad.jp>
# Author: Kazu Yamamoto <Kazu@Mew.org>
# Created: Jul 20, 2006
# Revised: Jul 25, 2006
ESTCMD=estcmd
FIND=find
RM=rm
MKDIR=mkdir
BASEDIR=${HOME}/Mail
INDEXDIR_ORG=casket
INDEXDIR_REPLICA=casket_replica
INDEXDIR=${INDEXDIR_ORG}
OUTPUT=${OUTPUT:-/dev/null}
LOCK=${BASEDIR}/.mewest.lock
CYGWINENV=no
SUFFIX=${SUFFIX:-.mew}
usage () {
PROG=`basename $0`
cat <<__HDT__
USAGE: ${PROG} [directory]
-s specify suffix
-h help
-v verbose mode
-b base dir
__HDT__
exit 1
}
cleanup () {
${RM} -fr "${LOCK}"
clean_up_replica
}
cleanup_trap () {
cleanup
exit 4
}
cleanup_exit () {
echo $1
cleanup
exit 4
}
clean_up_replica () {
if [ -d "${BASEDIR}/${INDEXDIR_REPLICA}" ]; then
rm -fr "${BASEDIR}/${INDEXDIR_REPLICA}"
fi
}
# Check if environment is Cygwin.
check_cygwin () {
if type uname > /dev/null
then
true
else
return 255
fi
case `uname -s` in
CYGWIN*)
if type cygpath > /dev/null
then
return 1
else
return 255
fi
;;
*)
return 0
;;
esac
}
# Convert path style from Unix to Windows if environment is Cygwin.
# Otherwise same path is simply echoed.
path_conv() {
if [ $CYGWINENV = "yes" ];
then
cygpath -w "$1"
else
echo "$1"
fi
}
check_cygwin
case $? in
0)
CYGWINENV=no
;;
1)
CYGWINENV=yes
# There is native find.exe in Windows but it is incompatible
# with Unix's one. So make sure Cygwin's find.exe is used.
PATH=/usr/bin:/bin:$PATH
;;
*)
echo Environment check failed
exit 255
;;
esac
while getopts "b:hvs:" OPTION
do
case ${OPTION} in
b)
BASEDIR=${OPTARG}
;;
h)
usage
;;
v)
OUTPUT=/dev/stdout
;;
s)
SUFFIX=${OPTARG}
;;
*)
usage
;;
esac
done
shift `expr $OPTIND - 1`
TGTDIR=${1:-${BASEDIR}}
trap cleanup_trap 1 2 3 9 15
# create and check lock
if ${MKDIR} "${LOCK}" > /dev/null 2>&1 ; then
true
else
echo "${LOCK} exists"
exit 5
fi
# Directory exist?
if [ ! -d "${TGTDIR}" ]; then
cleanup_exit "${TGTDIR} not found"
fi
if [ -d "${BASEDIR}/${INDEXDIR}" ]; then
echo "Replicating index..."
clean_up_replica
cp -R "${BASEDIR}/${INDEXDIR}" "${BASEDIR}/${INDEXDIR_REPLICA}"
INDEXDIR=${INDEXDIR_REPLICA}
echo "Replicating index...done"
echo "Purging old messages..."
${ESTCMD} purge "`path_conv \"${BASEDIR}/${INDEXDIR}\"`" "`path_conv \"${TGTDIR}\"`" > ${OUTPUT} ||\
cleanup_exit "Purging old messages...failed"
echo "Purging old messages...done"
fi
echo "Indexing new messages..."
# "find"'s regular expression is NOT portable, sigh...
# "[0-9]*" matches both "123" and "234.mew".
${FIND} "`path_conv \"${TGTDIR}\"`" \
-type d -name "trash" -prune -o \
-type d -name ${INDEXDIR_ORG} -prune -o \
-type d -name ${INDEXDIR_REPLICA} -prune -o \
-type f \( -name "[0-9]" -o -name "[0-9]*[0-9]" -o -name "[0-9]*${SUFFIX}" \) -print |\
${ESTCMD} gather -cl -fm -cm -sd -xh "`path_conv \"${BASEDIR}/${INDEXDIR}\"`" - > ${OUTPUT} ||\
cleanup_exit "Indexing new messages...failed"
echo "Indexing new messages...done"
if [ "${BASEDIR}/${INDEXDIR}" = "${BASEDIR}/${INDEXDIR_REPLICA}" ]; then
echo "Replacing old index with new one..."
rm -fr "${BASEDIR}/${INDEXDIR_ORG}"
mv "${BASEDIR}/${INDEXDIR_REPLICA}" "${BASEDIR}/${INDEXDIR_ORG}"
echo "Replacing old index with new one...done"
fi
cleanup
exit 0
# Copyright (C) 2006-2007 Mew developing team.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the team nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE TEAM AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE TEAM OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|