From 384a19e966a688ba67f564e9d61beb02038734d4 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Fri, 15 Mar 2019 12:48:36 -0400 Subject: _ob_try_load_messages(): Replace . with eval/cat --- (limited to 'lib') 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 } -- cgit v0.9.1