#!/bin/csh -f
#+
# dir -- list FITS images in the current output directory
#
# Purpose:
#	Print a list of all FITS files in the data directory
#
# Usage:
#	dir [flags]
# 
# Arguments:
#	flags = any legal flags for the "ls" command
# 
# Output:
#	a list of files is printed to the standard output
# 
# Exit values:
#	0 = normal completion
#	1 = wrong number of arguments
#	2 = output directory not found
#
# Example:
#	1) obtain a short listing of files in the output directory:
#		dir
#	2) obtain a long listing:
#		dir -l
#-
# Modification history:
#	2000-Jul-04	GDW	Original version
#       2002-Jun-06     GDW     Adapted for DEIMOS
#-----------------------------------------------------------------------

# get the output directory...
set dir = `show -s deiccd -terse outdir`

if ( $status != 0 ) then
  echo "Error reading outdir"
  exit 2
endif

if ( ! -e $dir ) then
  echo "Output directory $dir not found"
  exit 2
endif

# execute commands in subshell to prevent changing current directory...
echo "FITS files in output directory ${dir}:"
( cd $dir ; \ls $* *.fits )
