Skip to content

Shell script hardening: set -euo pipefail across all scripts#40

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/set-euo-pipefail-in-scripts
Draft

Shell script hardening: set -euo pipefail across all scripts#40
Copilot wants to merge 3 commits into
mainfrom
copilot/set-euo-pipefail-in-scripts

Conversation

Copilot AI commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Scripts used only set -e, leaving unset variable references silently expanding to empty strings and pipe failures going undetected — both dangerous when handling secrets or rendering configs.

Changes

  • #!/bin/sh#!/bin/bash on all scripts — required since pipefail is a bash extension unavailable in POSIX sh/dash
  • set -e / set -euset -euo pipefail across all 17 scripts in scripts/ and config/postgres/init-databases.sh
  • lib.sh: changed sh "$pre_start_script""$pre_start_script" — explicit sh invocation bypasses the shebang, running under dash and silently dropping pipefail
# Before
#!/bin/sh
set -e

# After
#!/bin/bash
set -euo pipefail

📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

Copilot AI linked an issue Mar 27, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Update scripts to use set -euo pipefail for safety Shell script hardening: set -euo pipefail across all scripts Mar 27, 2026
Copilot AI requested a review from florianajir March 27, 2026 14:26
@florianajir

Copy link
Copy Markdown
Owner

@copilot test failed fix it

Copilot AI commented Mar 27, 2026

Copy link
Copy Markdown
Contributor Author

@copilot test failed fix it

Fixed in eb0f844. The CI workflow was invoking scripts with sh ./scripts/authelia-pre-start.sh which bypasses the shebang and runs under dash — which doesn't support -o pipefail. Updated the two calls in .github/workflows/ci.yml to use bash instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shell Script Hardening

2 participants