From b723fbcd980d307ff74a2ebf59a94a780c5f79b6 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Sat, 29 May 2021 15:14:33 +0200 Subject: sfeed_opml_export: sync loadconfig() function fixes from sfeed_update - Do not show stderr of readlink. - Show the reference to the example sfeedrc (like sfeed_update). - Make the error message a bit shorter. - Fix showing the path if it does not exist, for example: $ sfeed_opml_export "a" readlink: a: No such file or directory Configuration file "" does not exist or is not readable. Now shows: $ sfeed_opml_export "a" Configuration file "a" cannot be read. See sfeedrc.example for an example. --- sfeed_opml_export | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'sfeed_opml_export') diff --git a/sfeed_opml_export b/sfeed_opml_export index d15cbba..835a576 100755 --- a/sfeed_opml_export +++ b/sfeed_opml_export @@ -4,20 +4,22 @@ # loadconfig(configfile) loadconfig() { # allow to specify config via argv[1]. - if [ ! x"$1" = x"" ]; then - # get absolute path of config file. - config=$(readlink -f "$1") + if [ "$1" != "" ]; then + # get absolute path of config file required for including. + config="$1" + path=$(readlink -f "${config}" 2>/dev/null) else # default config location. config="$HOME/.sfeed/sfeedrc" + path="${config}" fi - # load config: config is loaded here to be able to override above variables - # (sfeedpath, sfeedfile, etc). - if [ -r "$config" ]; then - . "$config" + # config is loaded here to be able to override $sfeedpath or functions. + if [ -r "${path}" ]; then + . "${path}" else - echo "Configuration file \"$config\" does not exist or is not readable." >&2 + echo "Configuration file \"${config}\" cannot be read." >&2 + echo "See sfeedrc.example for an example." >&2 exit 1 fi } -- cgit v1.2.3