summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2019-03-15 12:48:36 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2019-03-15 12:48:36 (EDT)
commit384a19e966a688ba67f564e9d61beb02038734d4 (patch)
tree1c5204e60c21238a2ee30290998b92f262266cde /lib
parent9a90a0dc9d5e1c10f34daad5d296a0373e7a9a51 (diff)
_ob_try_load_messages(): Replace . with eval/cat
Diffstat (limited to 'lib')
-rw-r--r--lib/locale.sh12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/locale.sh b/lib/locale.sh
index 7b69873..874d376 100644
--- a/lib/locale.sh
+++ b/lib/locale.sh
@@ -43,12 +43,12 @@ _ob_try_load_messages()
ms="$(printf "${_OB_LOCALE_PATH}" \
"${locale}" "${_ob_text_domain}")"
- if [ -f "${ms}" ]; then
- . "${ms}"
- else
- return 1
- 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)" || return 1
return 0
}