- Replace grep -oP (Perl regex) with portable sed — fixes "grep: invalid option -- P" on macOS
- Add sedi() wrapper for cross-platform sed -i (BSD vs GNU)
- Detect macOS via uname and use apple-darwin binary suffix instead of linux-musl
- Add is_native_binary() helper: checks both ELF (Linux) and Mach-O (macOS)
- macOS env vars: use launchctl setenv + /etc/codex-env.sh + ~/.zshrc source line
- Linux env vars: keep /etc/environment + /etc/profile.d/ as before
- Wrapper script uses dynamic ENV_FILE path instead of hardcoded /etc/profile.d/
- Fix SUDO_USER handling for correct ~/.zshrc path when run via sudo
- Uninstaller: also remove .codex-bin, /etc/codex-env.sh, launchctl vars, rc file entries
- Uninstaller: scan /Users/* on macOS instead of /home/*
- Fix CRLF line endings in ucodex_uninstall.sh
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Problem: `sudo bash install.sh` runs in child process, `export` inside it
never reaches the user's current shell. /etc/environment and /etc/profile.d/
only work for NEW sessions. So `codex`/`gemini`/`qwen` fail with
"Missing environment variable" right after install.
Solution: wrapper scripts that auto-source env file before exec'ing binary.
- codex: /usr/local/bin/codex (wrapper) -> /usr/local/bin/.codex-bin (real)
- gemini: /usr/local/bin/gemini (wrapper) -> node .../dist/index.js
- qwen: /usr/local/bin/qwen (wrapper) -> node .../dist/index.js
Works immediately in ANY shell, no manual `source` needed.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Write OPENAI_API_KEY and OPENAI_BASE_URL to /etc/environment (all users)
- Create /etc/profile.d/codex-env.sh for login shell export (all users)
- Export for current session too
- Removes per-user ~/.bashrc approach — system-wide is more reliable
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Install/update scripts now:
- Export env vars for current session (fixes "Missing OPENAI_API_KEY")
- Write to ~/.bashrc or ~/.zshrc for persistence
- Handle sudo (detect real user via SUDO_USER)
- Remove stale entries before writing
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>