fix: false positive on verify_install script being external shell (#1704)

- Introduced a new test script for shell detection logic in
`verify_install.sh`.
- Updated the `package.json` to include a new test command for shell
detection.
- Enhanced the `verify_install.sh` script to accurately check the
current shell interpreter using `/proc` and fallback methods.

This improves the testing framework and ensures better validation of
shell detection functionality.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- Bug Fixes
- Installer now detects the actual interpreter more robustly and
strictly requires Bash; non-Bash environments produce clear error
messages and abort installation.
- Tests
- Added automated shell-detection tests to validate behavior across
environments.
- Test suite expanded to run the new shell-detection checks as part of
the standard test command.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
Eli Bosley
2025-09-15 12:17:50 -04:00
committed by GitHub
parent 167857a323
commit 31a255c928
3 changed files with 174 additions and 6 deletions

View File

@@ -6,11 +6,19 @@
check_shell() {
# This script runs with #!/bin/bash shebang
# On Unraid, users may configure bash to load other shells through .bashrc
# We check if the current process ($$) is actually bash, not another shell
# Using $$ is correct here - we need to detect if THIS process is running the expected bash
# We need to check if the interpreter running this script is actually bash
# Use readlink on /proc to find the actual interpreter, not the script name
local current_shell
current_shell=$(ps -o comm= -p $$)
# Get the actual interpreter from /proc
if [ -e "/proc/$$/exe" ]; then
current_shell=$(readlink "/proc/$$/exe")
else
# Fallback to checking the current process if /proc isn't available
# Note: This may return the script name on some systems
current_shell=$(ps -o comm= -p $$)
fi
# Remove any path and get just the shell name
current_shell=$(basename "$current_shell")