Hello
So i have that script collection, in which i have a single script to create a configuration file.
In there, i have multiple occourences of something like this:
prj_title=$(tui-read "What is the TITLE? ($prj_name):")
[[ -z "$prj_title" ]] && prj_title="${prj_name/_/ }"
They all work as expected, if nothing is entred, it fills the variable with the default value.
However, for this it fails, and i fail to figure out why:
#
# Ask for a value, if value is empty, fill it with default
#
prj_tempdird="/tmp/${prj_name}_$ARCH"
prj_tempdir=""
#prj_tempdir=$(tui-read "What is the temp directory? ($prj_tempdird):")
read -p "What is the temp directory? ($prj_tempdird):" prj_tempdir
[[ -z "$prj_tempdir" ]] && prj_tempdir="$tempdird"
[[ -z $prj_tempdir ]] && prj_tempdir="$tempdird"
[[ "" = "$prj_tempdir" ]] && prj_tempdir="$tempdird"
[[ "" = "$(echo $prj_tempdir)" ]] && prj_tempdir="$tempdird"
[[ "" = "$(echo $prj_tempdir|tr -d [[:space:]])" ]] && prj_tempdir="$tempdird"
[[ -z "$(echo $prj_tempdir)" ]] && prj_tempdir="$tempdird"
echo "$prj_tempdir =! $prj_tempdird"
This is what i get:
:) ~ $ sh file1.txt
What is the temp directory? (/tmp/_):/home/TEMP
/home/TEMP =! /tmp/_ (this is 'expected')
+ ~ $ sh file1.txt
What is the temp directory? (/tmp/_):
=! /tmp/_ (this is NOT)
+ ~ $
This is what i expect:
+ ~ $ sh file1.txt
What is the temp directory? (/tmp/_):
/tmp/_ =! /tmp/_
Any ideas please?
Thank you in advance