#!/bin/bash function blah() { test "${DELDIR}" == "" && echo "The next line is bash doing it wrong" if [ -d ${DELDIR} ] then echo "Executing: rm -rf ${DELDIR}/*" else echo "No." fi } echo "Trying to delete content of directory defined in an undefined variable ..." blah echo "Trying to delete based on nonexisting directory (empty string is not a valid directory) ..." DELDIR= blah echo "Doing it wrong by deleting /bin/bash/* ..." DELDIR=/bin/bash blah echo "Trying to delete real directory content ..." DELDIR=/tmp blah cat << 'END' Fix (?) Man kan använda if [ -d "${DELDIR}" ] istället. Men det minsta bash kunde ha klagat på är ett syntax error eller linande när man testar [ -d ${DELDIR} ] då DELDIR är odefinerat. END