dbc944d46c
Remove the same-user mutable temporary script from the macOS CLI installer privilege boundary. The installer now passes the bundled helper path to AppleScript as an argument, quotes it inside AppleScript, and builds the privileged symlink command in memory before invoking `bash -c` with administrator privileges. Existing symlink targets are preserved: `/usr/local/bin/codexbar` and `/opt/homebrew/bin/codexbar`. Proof: - bash -n bin/install-codexbar-cli.sh - extracted AppleScript heredoc compiles with osacompile - static checks confirmed mktemp/install_script/bash temp-file handoff removed - git diff --check - make check - autoreview clean - CI green on PR head 6b329567
30 lines
986 B
Bash
Executable File
30 lines
986 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
APP="/Applications/CodexBar.app"
|
|
HELPER="$APP/Contents/Helpers/CodexBarCLI"
|
|
TARGETS=("/usr/local/bin/codexbar" "/opt/homebrew/bin/codexbar")
|
|
|
|
if [[ ! -x "$HELPER" ]]; then
|
|
echo "CodexBarCLI helper not found at $HELPER. Please reinstall CodexBar." >&2
|
|
exit 1
|
|
fi
|
|
|
|
osascript - "$HELPER" <<'APPLESCRIPT'
|
|
on run argv
|
|
set helperPath to item 1 of argv
|
|
set installCommand to "set -euo pipefail" & linefeed & ¬
|
|
"HELPER=" & quoted form of helperPath & linefeed & ¬
|
|
"TARGETS=(\"/usr/local/bin/codexbar\" \"/opt/homebrew/bin/codexbar\")" & linefeed & ¬
|
|
"for t in \"${TARGETS[@]}\"; do" & linefeed & ¬
|
|
" mkdir -p \"$(dirname \"$t\")\"" & linefeed & ¬
|
|
" ln -sf \"$HELPER\" \"$t\"" & linefeed & ¬
|
|
" echo \"Linked $t -> $HELPER\"" & linefeed & ¬
|
|
"done"
|
|
|
|
do shell script "bash -c " & quoted form of installCommand with administrator privileges
|
|
end run
|
|
APPLESCRIPT
|
|
|
|
echo "CodexBar CLI installed. Try: codexbar usage"
|