Skip to content

Instantly share code, notes, and snippets.

@forestbaker
Created September 29, 2015 17:55
Show Gist options
  • Save forestbaker/53e746e579861b6ee683 to your computer and use it in GitHub Desktop.
Save forestbaker/53e746e579861b6ee683 to your computer and use it in GitHub Desktop.
the triple decker super checker
# fast & efficient triple check:
# existence, directory, writable || or error and exit
[[ -e $DIR && -d $DIR && -w $DIR ]] || { echo >&2 "Unable to access $DIR - check directory path / permissions?" ; exit 1 ; }
# exists , file, readable
[[ -s $FILE && -d $FILE && -r $FILE ]] || { echo >&2 "Unable to access $FILE - check file path / permissions?" ; exit 1 ; }
# exists , file, writable
[[ -s $FILE && -d $FILE && -w $FILE ]] || { echo >&2 "Unable to access $FILE - check file path / permissions?" ; exit 1 ; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment