-
-
Notifications
You must be signed in to change notification settings - Fork 422
943 Local Setup - Kept Old US Local Setup In place #1344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
fd7b8d7
6ca16bd
0083377
c3c28d3
a729863
c48f44a
3ab80bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,71 @@ | ||||||||||||||||||||||||||||||||||||||
| #!/bin/sh -e | ||||||||||||||||||||||||||||||||||||||
| . ../common-script.sh | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| setLocale() { | ||||||||||||||||||||||||||||||||||||||
| if command_exists locale-gen; then | ||||||||||||||||||||||||||||||||||||||
| iso=$(curl -4fsSL --max-time 5 https://ifconfig.io/country_code 2>/dev/null) || iso="US" | ||||||||||||||||||||||||||||||||||||||
| suggested_locales=$(ls /usr/share/i18n/locales/ | grep -i "$iso" || true) | ||||||||||||||||||||||||||||||||||||||
|
Check warning on line 7 in core/tabs/utils/locale-setup.sh
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| if [ -z "$suggested_locales" ]; then | ||||||||||||||||||||||||||||||||||||||
| suggested_locales=$(ls /usr/share/i18n/locales/) | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+9
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win Use validated full UTF-8 locale identifiers. The fallback lists every file in Build choices and custom validation from Suggested input model- suggested_locales=$(ls /usr/share/i18n/locales/ | grep -i "$iso" || true)
+ supported_locales=$(awk '$2 == "UTF-8" { print $1 }' /usr/share/i18n/SUPPORTED)
+ suggested_locales=$(printf '%s\n' "$supported_locales" |
+ grep -iE "(^|_)${iso}([.@]|$)" || true)
if [ -z "$suggested_locales" ]; then
- suggested_locales=$(ls /usr/share/i18n/locales/)
+ suggested_locales=$supported_locales
fi
...
- if [ -f "/usr/share/i18n/locales/$custom_locale" ]; then
+ if [ "$custom_locale" = "C.UTF-8" ] ||
+ printf '%s\n' "$supported_locales" |
+ grep -qxF "$custom_locale"; thenAlso applies to: 24-40, 48-52 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| printf "%s\n" "Suggested locales based on your location ($iso):" | ||||||||||||||||||||||||||||||||||||||
| i=1 | ||||||||||||||||||||||||||||||||||||||
| for loc in $suggested_locales; do | ||||||||||||||||||||||||||||||||||||||
| printf " %d) %s\n" "$i" "$loc" | ||||||||||||||||||||||||||||||||||||||
| i=$((i + 1)) | ||||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||
| printf " %s\n" "c) Enter a custom locale" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| printf "%s" "Select a locale number (or 'c' for custom): " | ||||||||||||||||||||||||||||||||||||||
| read -r choice | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| if [ "$choice" = "c" ] || [ "$choice" = "C" ]; then | ||||||||||||||||||||||||||||||||||||||
| LOCALE="" | ||||||||||||||||||||||||||||||||||||||
| while [ -z "$LOCALE" ]; do | ||||||||||||||||||||||||||||||||||||||
| printf "%s" "Enter locale (e.g. en_US): " | ||||||||||||||||||||||||||||||||||||||
| read -r custom_locale | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| if [ -z "$custom_locale" ]; then | ||||||||||||||||||||||||||||||||||||||
| printf "%s\n" "Locale cannot be empty." | ||||||||||||||||||||||||||||||||||||||
| continue | ||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| if [ -f "/usr/share/i18n/locales/$custom_locale" ]; then | ||||||||||||||||||||||||||||||||||||||
| LOCALE="$custom_locale" | ||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||
| printf "%s\n" "'$custom_locale' is not a recognized locale. Please try again." | ||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||
| case "$choice" in | ||||||||||||||||||||||||||||||||||||||
| ''|*[!0-9]*) | ||||||||||||||||||||||||||||||||||||||
| printf "%s\n" "Invalid selection." | ||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||||
| esac | ||||||||||||||||||||||||||||||||||||||
| LOCALE=$(printf "%s\n" "$suggested_locales" | sed -n "${choice}p") | ||||||||||||||||||||||||||||||||||||||
| if [ -z "$LOCALE" ]; then | ||||||||||||||||||||||||||||||||||||||
| printf "%s\n" "Invalid selection." | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+42
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/sh
set -eu
echo "== locate file =="
fd -a 'locale-setup.sh' . || true
echo "== relevant file excerpt =="
if [ -f core/tabs/utils/locale-setup.sh ]; then
nl -ba core/tabs/utils/locale-setup.sh | sed -n '1,90p'
fi
echo "== sed on input 0p =="
printf 'line\n' | sed -n '0p' || true
printf 'line\n' | sed -n '1p' || true
echo "== sed availability =="
sed --version | head -n 1 || trueRepository: ChrisTitusTech/linutil Length of output: 424 🏁 Script executed: #!/bin/sh
set -eu
echo "== relevant file excerpt =="
if [ -f core/tabs/utils/locale-setup.sh ]; then
awk '{printf "%3d\t%s\n", NR, $0}' core/tabs/utils/locale-setup.sh | sed -n '1,120p'
fi
echo "== shell behavior for sed 0p under set -e =="
tmp="$(mktemp)"
trap 'rm -f "$tmp"' EXIT
printf 'line\n' > "$tmp"
(
set -e
sed -n '0p' "$tmp"
status=$?
printf 'sed status: %s\n' "$status"
)
status=${status:-0}
printf 'outer status: %s\n' "$status"Repository: ChrisTitusTech/linutil Length of output: 3027 Reject The menu uses 1-based numbering, but the current validation allows Minimal fix for zero- ''|*[!0-9]*)
+ ''|0|*[!0-9]*)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| if ! grep -qxF "${LOCALE} UTF-8" /etc/locale.gen 2>/dev/null; then | ||||||||||||||||||||||||||||||||||||||
| printf '%s UTF-8\n' "$LOCALE" | "$ESCALATION_TOOL" tee -a /etc/locale.gen >/dev/null | ||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||
| if grep -q '^LANG=' /etc/locale.conf 2>/dev/null; then | ||||||||||||||||||||||||||||||||||||||
| "$ESCALATION_TOOL" sed -i "s/^LANG=.*/LANG=${LOCALE}/" /etc/locale.conf | ||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||
| printf 'LANG=%s\n' "$LOCALE" | "$ESCALATION_TOOL" tee -a /etc/locale.conf >/dev/null | ||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||
| "$ESCALATION_TOOL" locale-gen "${LOCALE}" | ||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||
| printf "%b\n" "ERROR! locale-gen not found; cannot generate locales on this system." | ||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| checkEnv | ||||||||||||||||||||||||||||||||||||||
|
technicks89 marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||||
| setLocale | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: ChrisTitusTech/linutil
Length of output: 5204
🏁 Script executed:
Repository: ChrisTitusTech/linutil
Length of output: 3681
Validate the country code before filtering locales.
isocomes from an HTTP response and is used unanchored ingrep. Use^[A-Za-z]{2}$and searchlocaleNamesfor an exact territory match such as_CA, so false positives likeca_*and emptyisovalues do not entersuggested_locales.🤖 Prompt for AI Agents