From 882d8f559c42732e779aaec92a800d310f0291c1 Mon Sep 17 00:00:00 2001 From: Qiufeng Date: Tue, 4 Aug 2026 00:33:16 +0800 Subject: [PATCH] fix: support piped installer execution --- install.sh | 2 +- tests/release-scripts.test.sh | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index f9cbc0e..8ecdef3 100755 --- a/install.sh +++ b/install.sh @@ -520,6 +520,6 @@ main() { say "Local URL: http://127.0.0.1:${ERP_SERVER_PORT:-8091}" } -if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then +if [[ "${BASH_SOURCE[0]:-$0}" == "$0" ]]; then main "$@" fi diff --git a/tests/release-scripts.test.sh b/tests/release-scripts.test.sh index f5d96a9..64b1aef 100755 --- a/tests/release-scripts.test.sh +++ b/tests/release-scripts.test.sh @@ -498,6 +498,14 @@ test_release_workflow_uses_scoped_job_token() ( ! grep -Fq 'vars.GITEA_BASE_URL' "$workflow" ) +test_installer_runs_when_piped_to_bash() ( + local output status=0 + output="$(ERP_GITEA_BASE_URL= bash -s -- --no-service < "$PROJECT_ROOT/install.sh" 2>&1)" || status=$? + [[ "$status" -ne 0 ]] + [[ "$output" == *'[ERP Install] ERROR:'* ]] + [[ "$output" != *'BASH_SOURCE'* ]] +) + run_test 'erp-run preserves Java option arguments' test_erp_run_preserves_java_option_arguments run_test 'installer accepts a correctly signed archive' test_installer_verifies_signed_safe_archive run_test 'installer rejects symlinks in release archives' test_installer_rejects_archive_symlinks @@ -510,6 +518,7 @@ run_test 'noninteractive install reports a missing database password' test_nonin run_test 'installer requires an explicit Gitea URL' test_installer_requires_explicit_gitea_url run_test 'no-service install disables online update' test_no_service_install_disables_online_update run_test 'release workflow uses the scoped Gitea job token' test_release_workflow_uses_scoped_job_token +run_test 'installer starts correctly when piped to bash' test_installer_runs_when_piped_to_bash printf 'RESULT pass=%s fail=%s\n' "$PASS" "$FAIL" [[ "$FAIL" -eq 0 ]]