add proper error handling for all final exec calls
[hband-tools.git] / user-tools / locale-validator
blob3cd7cebcded48503083ef654865f96eb9bd710b7
1 #!/bin/bash
3 # outputs locale variable names (LANG, LC_MESSAGE, LC_ALL, ...) which
4 # are found to be unavailable on the system.
6 set -e
7 . /usr/lib/tool/bash-utils
10 locale |\
12 locales=($(locale -a))
13 localecodes=($(for locale in "${locales[@]}"; do echo ${locale%%.*}; done))
14 languagecodes=($(for localecode in "${localecodes[@]}"; do echo ${localecode%%_*}; done))
16 while IFS='=' read option settings
18 valid=no
19 settings=${settings//\"/}
21 if [ -z "$settings" ]
22 then
23 continue
26 for setting in ${settings//:/ }
28 parts=(${setting/./ })
29 langcode=${parts[0]}
30 charset=${parts[1]}
31 charset=${charset//-/}
32 charset=${charset,,}
34 if [ -z "${langcode//[!_]/}" ]
35 then
36 setting=$langcode
37 list=("${languagecodes[@]}")
38 elif [ -n "$charset" ]
39 then
40 setting=$langcode.$charset
41 list=("${locales[@]}")
42 else
43 setting=$langcode
44 list=("${localecodes[@]}")
47 if in_list "$setting" "${list[@]}"
48 then
49 valid=yes
50 break
52 done
54 if [ $valid = no ]
55 then
56 echo $option
58 done