EDIT: -- SOLVED --
Heyas,
Getting used to optargs, but by far not understanding it.
So i have that script that shall be 'changeable', trying to use the passed arguments to modify the script visuals.
Passing:
browser -t test -d sect $HOME
Where -t
should change the title,
and -d
should change the 'dir-label'.
While the title works, the 'dir-label' doesnt.
set -x
while getopts "m:d:f:t:u:h(help)": name
do #echo "$name -- $OPTARG -- $OPTIND" # DEBUG help TODO rm when working
case $name in
t|title) lbl_title="$OPTARG" ;;
u|user) lbl_user="$OPTARG" ;;
d|dir) lbl_dir="$OPTARG" ;;
f|file) lbl_file="$OPTARG" ;;
m|mode) mode="$OPTARG" ;;
h|help) printf "$help_text"
exit $RET_HELP ;;
esac
done
shift $(($OPTIND - 1))
set +x
[ -z $lbl_dir ] && tui-echo "Error retrieving 'Folders'-label..." "$FAIL" && exit 1
Output 1:
$ tui-browser -t test -d sect $HOME
t -- test -- 3
d -- sect -- 5
# | Error retrieving 'Folders'-label... [ ] | #
Output 2:
$ tui-browser -t test -d sect $HOME
+ getopts 'm:d:f:t:h(help):' name
+ echo 't -- test -- 3'
t -- test -- 3
+ case $name in
+ lbl_title=test
+ getopts 'm:d:f:t:h(help):' name
+ echo 'd -- sect -- 5'
d -- sect -- 5
+ case $name in
+ lbl_dir=
+ getopts 'm:d:f:t:h(help):' name
+ set +x
# | Error retrieving 'Folders'-label... [ ] | #
I dont understand how lbl_dir is set to empty?
Could you bring in some light please?
Thank you in advance
EDIT:
Added the red-colored part, and it worked as expected, wierd...
Thought, i wasnt testing what i just added..