summaryrefslogtreecommitdiff
path: root/sfeed_opml_export
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2021-05-29 15:14:33 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2021-05-29 15:14:33 +0200
commitb723fbcd980d307ff74a2ebf59a94a780c5f79b6 (patch)
tree166783e69b513f81480b235dee98732cacf84bde /sfeed_opml_export
parent02b590f6a23ab775535ab96614eb467156e8abe6 (diff)
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.
Diffstat (limited to 'sfeed_opml_export')
-rwxr-xr-xsfeed_opml_export18
1 files changed, 10 insertions, 8 deletions
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
}