2
# @(#)ed_moptions.sh 19.1 (ESO-IPG) 02/25/03 13:51:10
3
# .COPYRIGHT: Copyright (c) 1988 European Southern Observatory,
6
# .NAME ed_make_options.sh
7
# .LANGUAGE shell script
8
# .ENVIRONMENT Unix Systems. Executable under SHELL and C-SHELL
9
# .COMMENTS Editing the file make_options.
11
# .AUTHOR Carlos Guirao
12
# .VERSION 1.1 17-Jul-1992: Implementation
13
# .VERSION 2.1 20-Jan-1993: "ex" instead of "ed" (for PC/Linux)
14
# .VERSION 3.1 990324 Checking EDITOR (default ex, otherwise ed)
17
echo "Usage: $0 get/replace/add/delete key[=options]"
21
if [ "$1" != "get" -a "$1" != "replace" -a "$1" != "add" -a "$1" != "delete" ]; then
22
echo "Usage: $0 get/replace/add/delete key[=options]"
26
if [ "$1" != "delete" -a $$ -lt 2 ]; then
27
echo "Usage: $0 replace/add key=options"
32
# Check if 'ex' editor exists otherwise use 'ed'
33
# "ed" is substituted by "ex" for PC/Linux except in SuSE
41
if [ -z "$MID_HOME" ]; then
42
cd `echo $0 | sed -e 's/[^\/]*$//' -e 's/^$/./' -e 's/\/$//'`
44
VERSDIR=`echo $MID_INSTALL | sed 's/\/install\/unix$//'`
45
MIDVERS=`echo $VERSDIR | sed -e 's/^.*\///'`
46
MIDASHOME=`echo $VERSDIR | sed -e 's/[^\/]*$//' -e 's/^$/./' -e 's/\/$//'`
47
MID_HOME=$MIDASHOME/$MIDVERS
50
file=$MID_HOME/local/make_options
52
key=`echo $2 | awk -F= '{print $1}'`
53
options=`echo $2 | sed 's/^'$key'=//'`
54
options=`eval echo $options`
58
oldoptions=`grep "^${key}=" $file | sed 's/^'$key'=//'`
61
if [ -n "$oldoptions" ]; then
65
if [ "$op" = "get" ]; then
69
# Remove previous definition of $key if existed
70
$EDITOR $file << EOF >/dev/null 2>&1
77
if [ "$op" = "delete" ]; then
81
if [ "$op" = "add" ]; then
82
options=`eval echo $oldoptions $options`
85
if [ -n "$options" ]; then
86
echo "$key=$options" >> $file