#!/bin/bash
######################################################
# Author : Simona Flavoni for NEMO
# Contact : sflod@locean-ipsl.upmc.fr
#
# Some functions called from makenemo_fcm
# Fclean_config   : config removing 
######################################################
#set -x
set -o posix
#set -u
#set -e
#+
#
# ================
# Fclean_config.sh
# ================
#
# --------------------------
# Remove the configuration
# --------------------------
#
# SYNOPSIS
# ========
#
# ::
#
#  $ Fclean_config.sh CONFNAME
#
#
# DESCRIPTION
# ===========
#
#
# Remove the configuration:

#
# EXAMPLES
# ========
#
# ::
#
#  $ ./Fclean_config.sh
#
#
# TODO
# ====
#
# option debug
#
#
# EVOLUTIONS
# ==========
#
# $Id: Fclean_config.sh 2158 2010-10-20 17:30:03Z sflod $
#
#
#
#   * creation
#
#-
 NEW_CONF=${x_n}
 echo "Removing bad configuration : ${NEW_CONF}" 
 echo "Are you sure that you want to remove this directory ? [y/n] "
 read answer
 answer=`echo $answer | sed 's/^[y].*$/y/'`
 if [  -z "$answer" -o "x$answer" = "xy" ]; then
 	# testing if configuration exists
 	if [ "$(cat ${COMPIL_DIR}/cfg.txt | grep "${NEW_CONF} ")"  == "" ] ; then
		echo "The configurationn_config.sh ${NEW_CONF} does not exist"     
		echo "No removing configuration"
		echo " "
        else
		rm -rf ${CONFIG_DIR}/${NEW_CONF}
		sed -e "/${NEW_CONF} /d"  ${COMPIL_DIR}/cfg.txt >  ${COMPIL_DIR}/cfg.tmp
		mv  ${COMPIL_DIR}/cfg.tmp  ${COMPIL_DIR}/cfg.txt
		echo "${NEW_CONF} configuration REMOVED" 
        fi
 else
	echo " "
	echo "nothing to remove"
 fi

 unset -v answer
