/usr/bin/mtnopt is in monotone 1.1-7.
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 | #! /bin/sh
# Copyright (C) 2008 Richard Levitte <richard@levitte.org>
#
# This program is made available under the GNU GPL version 2.0 or
# greater. See the accompanying file COPYING for details.
#
# This program is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE.
mtn_dir=.
mtn_keys=
shell_type=sh
if echo $SHELL | grep '/t?csh' > /dev/null; then shell_type=csh; fi
values_only=false
usage () {
echo "mtnopt: Usage: mtnopt [-c] [-s] [-d dir] [-k keys] [-v] [-h]"
}
while [ ! $# = 0 ]; do
case $1 in
-c)
shell_type=csh
;;
-s)
shell_type=sh
;;
-d*)
mtn_dir=`echo "$1" | sed -e 's/^-d//'`
if [ -z "$mtn_dir" ]; then shift; mtn_dir="$1"; fi
if [ -z "$mtn_dir" ]; then
echo "mtnopt: missing required argument for -d" >&2
usage
exit 1
fi
;;
-k*)
mtn_keys=`echo "$1" | sed -e 's/^-k//'`
if [ -z "$mtn_keys" ]; then shift; mtn_keys="$1"; fi
if [ -z "$mtn_keys" ]; then
echo "mtnopt: missing required argument for -k" >&2
usage
exit 1
fi
;;
-v)
values_only=true
;;
-h|--help)
usage
exit 0
;;
--version)
echo "mtnopt from monotone 1.1"
exit 0
;;
esac
shift
done
if [ ! -d "$mtn_dir" ]; then
echo "mtnopt: $mtn_dir isn't a directory or is missing"
exit 1
elif [ ! -d "$mtn_dir/_MTN" ]; then
echo "mtnopt: $mtn_dir isn't a monotone workspace"
exit 1
elif [ ! -f "$mtn_dir/_MTN/options" ]; then
echo "mtnopt: $mtn_dir/_MTN/options isn't a file or is missing"
exit 1
fi
cat $mtn_dir/_MTN/options | while read L; do
eval `echo "$L" | sed -e 's/^ *\([a-z][a-z]*\) \(.*\)$/key=\1; val=\2/'`
if [ -z "$mtn_keys" ] || echo "$key" | egrep "^$mtn_keys\$" > /dev/null; then
if $values_only; then
echo "$val"
else
if [ "$shell_type" = sh ]; then
echo "MTN_$key=\"$val\";"
else
echo "set MTN_$key=\"$val\";"
fi
fi
fi
done
|