#! /bin/sh
#
# @(#)pathcheck	1.3	LPS_UNX_COM	2/19/95
#
# Copyright 1993   Digital Equipment Corporation, Maynard, MA
#
# pathcheck
#
# A script to test for the existence of a specified path based on a
# specified file access type.  If the path and accesss type do not jive,
# then the user is asked for confirmation on the specification.
#
# Parameters:
#    $1 - The access type, one of the single letters used for determining
#	  path access with /bin/test (eg, "d", "r", etc).
#    $2 - The path string.
#
# The exit value is 0 if the path either exists according to the access
# type, or the user otherwise confirms its specification.  Otherwise, the
# exit value is 1 if the user enters 'n' (the default response for path
# confirmation).

if [ $1 = "d" ]
then
    pathtype="directory"
else
    pathtype="file"
fi

if [ -$1 $2 ]
then
    exit 0
else
    echo
    echo "\"$2\" either does not exist or is not a suitable $pathtype."
    yesno n "Are you sure you mean \"$2\""
    exit $?   # Returns the exit value from "yesno"
fi
