Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Default to fetching global locale

If all else fails, take the long route.
  • Loading branch information...
commit 93a0110a9fccca08aae3bc991c03ffdfbcadfd5b 1 parent eee25f7
Martin Kopischke authored

Showing 1 changed file with 7 additions and 7 deletions. Show diff stats Hide diff stats

  1. +7 7 src/lib/system.sh
14 src/lib/system.sh
@@ -4,11 +4,11 @@ function get_global_locale {
4 4
5 5 function get_locale {
6 6 local locale
7   - # get cached value if requested and present
8   - [[ $1 == '--cached' && -f "$2" ]] && locale=$(while read -r; do echo "$REPLY"; break; done < "$2")
9   - # get the defaults value if there is no cached value present, or if none has been requested
10   - [[ -z "$locale" ]] && locale=$(get_global_locale)
11   - # asynchronously refresh cache (if requested)
12   - [[ $1 == '--cached' ]] && { { mkdir -p "${2%/*}"; get_global_locale > "$2"; } & disown; }
13   - echo "$locale"
  7 + # get cached value if requested and present, refresh asynchronously
  8 + if [[ $1 == '--cached' ]]; then
  9 + [[ -f "$2" ]] && locale=$(while read -r; do echo "$REPLY"; break; done < "$2")
  10 + { { mkdir -p "${2%/*}"; get_global_locale > "$2"; } & disown; } 2>/dev/null
  11 + fi
  12 + # get the defaults value otherwise
  13 + [[ -n "$locale" ]] && echo "$locale" || get_global_locale
14 14 }

0 comments on commit 93a0110

Please sign in to comment.
Something went wrong with that request. Please try again.