#!/bin/sh

# clr_temp
# Copyright (C) 2025 Joseph Rosevear, San Diego CA, USA.

# This file is part of a distribution SAM.

# SAM is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your
# option) any later version.

# SAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.





# Definitions.
self=`basename $0`
index="$1"

if [ "$index" = "" ]; then

   temp_num=`temp_num`
   result="$?"

   # Is $result not "0"?
   if [ "$result" != "0" ]; then

      cat << DONE
   
$self: Error. Problem with temp_num.
DONE

      exit
   fi
   
   index=$temp_num
fi

# Is $sam_temp_base ""?
if [ "$sam_temp_base" = "" ]; then

   cat << DONE
   
$self: Error. \$sam_temp_base is "".
DONE

   exit
fi

# Is `dirname $sam_temp_dir` $sam_temp_base?
if [ "`dirname $sam_temp_dir`" != "$sam_temp_base" ]; then

   cat << DONE
   
$self: Error. \$sam_temp_dir does not contain \$sam_temp_base.
DONE

   exit
fi

# Remove $sam_temp_base/temp${index}/in_use.
rm $sam_temp_base/temp${index}/in_use
