fix(bootstrap): detect a missing terminal by opening /dev/tty
prompt_install_mode guarded its prompt with `[ ! -r /dev/tty ]`, which never fires on Linux: /dev/tty is mode 0666 whether or not the process has a controlling terminal, and only opening it fails. Without a terminal the menu was printed, the read failed with "No such device or address", and the default was taken by accident rather than by the documented path. The guard now opens /dev/tty in a subshell and takes the "no terminal for a prompt" path when that fails.
This commit is contained in:
2 files changed
+6
-4
No files matched your search
+3
-2
@@ -2240,8 +2240,9 @@ prompt_install_mode() {
|
||||
|
||||
# No override: ask on the controlling terminal. Under `curl | sudo bash` stdin
|
||||
# is the script, so we must read /dev/tty, not stdin. No tty (CI/cloud-init) →
|
||||
# take the default.
|
||||
if [ ! -r /dev/tty ]; then
|
||||
# take the default. Open it to find out: /dev/tty is mode 0666 on every Linux host, so
|
||||
# `-r` passes even when there is no controlling terminal and only the open fails.
|
||||
if ! (: </dev/tty) 2>/dev/null; then
|
||||
INSTALL_MODE="$def"
|
||||
log "no terminal for a prompt; defaulting to a ${def} install (set FELIS_INSTALL_MODE=full or nano to override)"
|
||||
return 0
|
||||
|
||||
Reference in new issue
Block a user