Testing

Use echo statements in place of commands to test

if [[ -d $dir_name ]]; then
    if cd $dir_name; then
        echo rm * # TESTING
    else
        echo "cannot cd to '$dir_name'" >&2
        exit 1
    fi
else
    echo "no such directory: '$dir_name'" >&2
    exit 1
fi
exit # TESTING

Important to develop and apply good test cases.

edge and corner cases.

  1. dirname contains the name of an existing directory
  2. dirname contains the name of a nonexistent directory
  3. dirname is empty.