summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2019-04-13 22:57:52 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2019-04-13 22:57:52 (EDT)
commit3eb82fb30a07f996f2d92549c008d2e9c1ec983e (patch)
tree41dcf93b10dc35cf0d47b3ca55a087c71f90c512
parent69beed026908861feb9eb4b648e3d537fe666a91 (diff)
_try_load_locale(): Replace . with eval/cat
-rw-r--r--src/locale.sh13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/locale.sh b/src/locale.sh
index 7ec9359..8a72926 100644
--- a/src/locale.sh
+++ b/src/locale.sh
@@ -31,10 +31,15 @@ _try_load_locale()
for ms in "${localedir}/${locale}/LC_MESSAGES/${TEXTDOMAIN}.ms" \
"${localedir}/${locale}.ms"; do
- if [ -f "${ms}" ]; then
- . "${ms}"
- return 0
- fi
+ # POSIX on the dot utility:
+ # "If no readable file is found, a non-interactive shell shall
+ # abort"
+ # So to survive an ENOENT or other error and display a more
+ # informative error message before aborting, we need this
+ # eval/cat command. This is more resilient against race
+ # conditions than `[ -f "${ms}" ]` is.
+ eval "$(cat "${ms}" 2>/dev/null)" || continue
+ return 0
done
return 1