I am a little new to bash scripting and I was trying to make this program capture a directory path from user and then check if the directory is present. It seems as if the variable SRC
inside the dir_input
function is not passed to dir_input
. Thanks in advance.
dir_input() {
echo -n "Enter targer directory: "
read SRC
}
dir_input_check() {
if [ ! -d "$SRC" ]; then
echo ERROR: "Target directory not found - Please try again."
dir_input
fi
}
dir_input
dir_input_check