From 3eb82fb30a07f996f2d92549c008d2e9c1ec983e Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Sat, 13 Apr 2019 22:57:52 -0400 Subject: _try_load_locale(): Replace . with eval/cat --- (limited to 'src') 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 -- cgit v0.9.1