diff --git a/scripts/install-cli.sh b/scripts/install-cli.sh index d1a05fb..4621d54 100755 --- a/scripts/install-cli.sh +++ b/scripts/install-cli.sh @@ -20,6 +20,11 @@ # set -eu +# Keep ASCII validation independent of the user's locale. On macOS, locale +# collation can make shell ranges such as [A-Z] match lowercase characters. +LC_ALL=C +export LC_ALL + if [ -z "${HOME:-}" ] && [ -z "${CHAT2DB_CLI_BIN_DIR:-}" ]; then echo "error: HOME is not set; set CHAT2DB_CLI_BIN_DIR to choose an install directory" >&2 exit 1 diff --git a/tests/install_cli_script.rs b/tests/install_cli_script.rs index 4fb76ff..4bfba22 100644 --- a/tests/install_cli_script.rs +++ b/tests/install_cli_script.rs @@ -373,6 +373,29 @@ mod unix_install_tests { ))); } + #[test] + fn install_script_accepts_manifest_base_under_non_c_locale() { + let temp = tempfile::tempdir().unwrap(); + let home = temp.path().join("home"); + fs::create_dir_all(&home).unwrap(); + let release = FakeRelease::start(); + let lowercase_manifest_base = release.manifest_base_url.replace("127.0.0.1", "localhost"); + + let output = run_installer( + &home, + Some("/bin/zsh"), + &release, + &["--no-modify-path"], + &[ + ("CHAT2DB_CLI_MANIFEST_BASE", &lowercase_manifest_base), + ("LC_ALL", "en_US.UTF-8"), + ], + ); + + assert_success(&output); + assert!(stdout(&output).contains("installed:")); + } + #[test] fn install_script_rejects_noncanonical_manifest_bases() { for base in [