-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
ls: add --quoting-style=locale support #8825
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?
Conversation
Implement locale-aware quoting for the ls command, allowing filenames to be quoted using locale-specific quotation marks based on the current LC_CTYPE setting. Features: - Add Quotes::Locale variant for locale-aware quoting - Create locale_quotes module with comprehensive locale mappings - Support 20+ languages with appropriate quote characters: * Romance languages (French, Spanish, etc.): guillemets * Germanic languages (German, Czech, etc.): low-9 and high quotes * Japanese: corner brackets * Chinese/Korean: CJK curly quotes * English/default: ASCII double quotes - Proper UTF-8 handling for multi-byte quote characters - Environment variable precedence: LC_ALL > LC_CTYPE > LANG - Localized help text in English and French Implementation: - Enhanced CQuoter to dynamically detect and apply locale quotes - Added --quoting-style=locale CLI option - Follows C-style quoting semantics (always-quote behavior) - Safe fallback to ASCII double quotes for unknown locales - Added spell-checker:ignore comments for technical terms Testing: - Verified with multiple locales (en_US, fr_FR, de_DE, ja_JP, zh_CN) - All existing tests pass - Help text properly localized
149b5e8
to
c25f9cd
Compare
GNU testsuite comparison:
|
GNU testsuite comparison:
|
532b9f4
to
c25f9cd
Compare
GNU testsuite comparison:
|
same comment, please write the summary yourself |
and needs tests |
Add test coverage for locale-aware quoting functionality: - Tests 10 different locales with appropriate quotation marks - Verifies English, French, German, Japanese, Chinese, Russian, Spanish, Polish, C, and POSIX locales - Tests escape sequence handling with locale quoting (newline character) - Validates UTF-8 encoding of multi-byte quote characters
GNU testsuite comparison:
|
CodSpeed Performance ReportMerging #8825 will improve performances by 3.03%Comparing Summary
Benchmarks breakdown
Footnotes
|
many jobs are failing |
Fix test failures by limiting locale tests to those available in the CI environment. CI only generates en_US.UTF-8, fr_FR.UTF-8, es_ES.UTF-8, and sv_SE.UTF-8. Removed tests for: de_DE, ja_JP, zh_CN, pl_PL, ru_RU.UTF-8 - These locales are not generated in .github/workflows/GnuTests.yml - The locale_quotes module unit tests still validate these quote types - This keeps the integration test CI-friendly while maintaining comprehensive coverage
GNU testsuite comparison:
|
Add missing Quotes::Locale test case in test_quotes_display() to ensure the Display trait implementation is tested for all quote variants. Add comprehensive unit tests for locale_quotes module: - Test locale environment variable precedence (LC_ALL > LC_CTYPE > LANG) - Validate quote character mappings for all supported locales - Ensure Romance, Germanic, Slavic, and Asian language quotes work correctly - Test locale string parsing with encoding and modifiers - Verify fallback behavior for unknown locales This adds 17 unit tests covering the locale detection and quote mapping functionality that was previously untested.
2279a7a
to
51bcdfe
Compare
…ariables Add test_ls_quoting_style_locale_env_vars to verify that --quoting-style=locale correctly responds to different locale environment variables (LC_ALL). Tests verify: - French locale (fr_FR.UTF-8) uses guillemets (« ») - Spanish locale (es_ES.UTF-8) uses guillemets (« ») - Swedish locale (sv_SE.UTF-8) uses ASCII quotes - C locale uses ASCII quotes Note: Environment variable precedence testing (LC_ALL > LC_CTYPE > LANG) is already comprehensively covered in unit tests (locale_quotes.rs). These integration tests focus on end-to-end functionality.
GNU testsuite comparison:
|
- Add locale/typography terms (CTYPE, Guillemets, guillemets) to spell checker dictionary - Skip newline filename test on Windows where such filenames are invalid
GNU testsuite comparison:
|
The
ls
command didn't support locale-aware filename quoting, making output less readable for non-English users.Solution: Added
--quoting-style=locale
option that readsLC_ALL
/LC_CTYPE
/LANG
and applies culturally appropriate quotation marks:« file »
„ file "
「 file 」
" file "
" file "
Changes:
Quotes::Locale
variant with locale detection module supporting 20+ languagesCQuoter
to handle multi-byte UTF-8 quote charactersPartially addresses #1872.