I'm interested in:
if [ -z "${var// }" ]...
if [ -d $dir ]...
More precisely, what is -z and -d? How can I call it and where can I read about this "keys"? And where can i find a full list of this "keys"?
Look at the manpage for test
man test
-z variable
will check condition if a variable is NULL then the condition will be TRUE if NOT then it will go to else
part of if
condition.
-d directory_name
will check if a directory name which is given next to it is present or not. If directory is present then condition will be TRUE or it will be FALSE.
From man test
-z STRING
the length of STRING is zero
-d FILE
FILE exists and is a directory
in bash manual invoked using
man -a bash
a section called CONDITIONAL EXPRESSIONS
which covers what you are looking for, in fact there are a whole bunch of basic to advanced concepts in there to look for.