smart_write
This commit is contained in:
+2
-1
@@ -238,8 +238,9 @@ function fix_locales {
|
|||||||
done
|
done
|
||||||
for locale in "${!found_locales[@]}"; do
|
for locale in "${!found_locales[@]}"; do
|
||||||
if [[ ${found_locales[$locale]} == 'false' ]]; then
|
if [[ ${found_locales[$locale]} == 'false' ]]; then
|
||||||
|
local language="${locale:0:5}"
|
||||||
echo "Locale: $locale missing"
|
echo "Locale: $locale missing"
|
||||||
sudo sed -i "s/^# *\(${locale:0:5}\.UTF-8\)/\1/" /etc/locale.gen
|
sudo /opt/miaou-bash/tools/smart_write /etc/locale.gen "(^# )?${language}\.UTF-8 UTF-8" "${language}.UTF-8 UTF-8"
|
||||||
should_regenerate=true
|
should_regenerate=true
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
+4
-4
@@ -1,14 +1,14 @@
|
|||||||
#!/usr/bin/env miaou-bash
|
#!/usr/bin/env miaou-bash
|
||||||
|
|
||||||
function usage {
|
function usage {
|
||||||
builtin echo "Usage: $(basename "$0") <REGEX> <STRING> <FILE>"
|
builtin echo "Usage: $(basename "$0") <FILE> <REGEX> <STRING>"
|
||||||
}
|
}
|
||||||
|
|
||||||
[[ $# -ne 3 ]] && usage && exit 2
|
[[ $# -ne 3 ]] && usage && exit 2
|
||||||
|
|
||||||
REGEX=$1
|
FILE=$1
|
||||||
STRING=$2
|
REGEX=$2
|
||||||
FILE=$3
|
STRING=$3
|
||||||
|
|
||||||
if ! grep -Pq "$REGEX" "$FILE"; then
|
if ! grep -Pq "$REGEX" "$FILE"; then
|
||||||
builtin echo -e "$STRING" >>"$FILE"
|
builtin echo -e "$STRING" >>"$FILE"
|
||||||
|
|||||||
Reference in New Issue
Block a user