There is a problem with function used to read user's input
readDefault()
{
ARGS=""
N=1
LOCALBUF=""
until [ $N -eq $# ]
do
eval ARG=\${$N}
ARGS=" $ARGS $ARG"
N=`expr $N + 1`
done
read $ARGS LOCALBUF
if [ -n "$LOCALBUF" ]
then
VARNAME=${!#}
export $VARNAME=$LOCALBUF
else
echo "Using current value."
fi
}
echo "Please type directory where the profiles are placed: \(current value: $PROFILESROOTDIR\)"
readDefault -e PROFILESROOTDIR
In this function the \ character is ignored from variable given by user and removed from it.
DO you have any ideea how to ignore the \ characters in this function?
The read command parses backslashes. If you have a reasonably modern shell, it might have read -r for "raw" input without any special treatment of backslashes.
I use the customized function so that if the user just press ENTER the variable's value is kept as the default one. If I use read -r PROFILESROOTDIR if the user just hits ENTER the variable will be set to empty.
I will user read -r inside the customized function.