Newer
Older
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
#!/bin/bash
######################################################
# Author : Rachid Benshila for NEMO
# Contact : rblod@locean-ipsl.upmc.fr
#
# Some functions called from makenemo
# Fcheck_config : config checking
######################################################
#set -x
set -o posix
#set -u
#set -e
#+
#
# ================
# Fcheck_config.sh
# ================
#
# --------------------------
# Check the configuration
# --------------------------
#
# SYNOPSIS
# ========
#
# ::
#
# $ Fcheck_config.sh FILENAME CONFNAME
#
#
# DESCRIPTION
# ===========
#
#
# Check the choice of the configuration:
#
# - Two cases
# - One is explicitely set
# - Nothing set, use the previous in use
#
# We use TOOLS/cfgs_DIR/cfg.txt to check if the configuration exists.
#
# EXAMPLES
# ========
#
# ::
#
# $ ./Fcheck_config.sh
#
#
# TODO
# ====
#
# option debug
#
#
# EVOLUTIONS
# ==========
#
# $Id: Fcheck_config.sh 9598 2018-05-15 22:47:16Z nicolasmartin $
#
#
#
# * creation
#
#-
declare -a ZTAB
if [ ${#2} -eq 0 ]; then
tail -1 ${CONFIG_DIR}/$1 > ${CONFIG_DIR}/cfg.tmp
read -a ZTAB < ${CONFIG_DIR}/cfg.tmp
NEW_CONF=${ZTAB[0]} ; TAB=( ${ZTAB[@]:1} )
\rm ${CONFIG_DIR}/cfg.tmp
echo "Warning !!!"
echo "No configuration specified"
echo "Use makenemo -n MYCONFIG"
echo "or makenemo -h for help"
echo "Using default configuration : ${NEW_CONF}"
fi
if [ "$1" == cfg.txt ]; then
cat ${CONFIG_DIR}/$1 | grep "${NEW_CONF} " > ${CONFIG_DIR}/cfg.tmp
read -a ZTAB < ${CONFIG_DIR}/cfg.tmp
NEW_CONF=${ZTAB[0]} ; TAB=( ${ZTAB[@]:1} )
\rm ${CONFIG_DIR}/cfg.tmp
fi
unset -v ZTAB