From 2a591c590b0799f64a8492bfb24b73f05f89db3a Mon Sep 17 00:00:00 2001 From: Ayush Agarwal Date: Fri, 18 Feb 2022 22:32:50 +0530 Subject: fix: set default values after argparse and config --- tessen | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/tessen b/tessen index 99fccfc..fd5e6fd 100755 --- a/tessen +++ b/tessen @@ -745,22 +745,8 @@ parse_config() { } main() { - # initialize basic options for users who expect sane defaults and don't use - # either the config file or args - if [[ -z $pass_backend ]]; then - find_pass_backend - fi - if [[ -z $dmenu_backend ]]; then - find_dmenu_backend - fi - validate_dmenu_backend "$dmenu_backend" - validate_action default - - # parse the config file - parse_config "$@" - - # parse command line arguments after the config file because args hold more - # precedence and priority than the config file + # parse arguments because they have the highest priority + # make the values supplied to -p, -d, and -a as readonly local _opt while [[ $# -gt 0 ]]; do _opt="$1" @@ -865,6 +851,21 @@ main() { readonly dmenu_backend_opts fi + # initialize basic options for users who expect sane defaults and don't use + # either the config file or args + if [[ -z $pass_backend ]]; then + find_pass_backend + readonly pass_backend + fi + if [[ -z $dmenu_backend ]]; then + find_dmenu_backend + validate_dmenu_backend "$dmenu_backend" + readonly dmenu_backend + fi + if [[ -z $tsn_action ]]; then + validate_action default + fi + trap '_clear' EXIT TERM INT if [[ $pass_backend == "pass" ]]; then get_pass_files -- cgit v1.2.3