summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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