Shell Scripting / Bash Tricks
Stop killing your production scripts by blindly piping into bash
🧩 The Challenge
Everyone has seen those curl-to-bash installation scripts that feel like a ticking time bomb. You never know if the network cut out halfway through and you just ran half a script against your database.
💡 The Fix
Use a temporary variable to hold the remote script or just inspect the payload before you blindly execute it. It saves you from accidentally running truncated code that wipes your configs.
curl -sSf https://example.com/install.sh | bash -s -- arg1 arg2
And if you want to be safe:
curl -sSf https://example.com/install.sh > /tmp/install.sh && sh /tmp/install.sh arg1 arg2
⚙️ Why It Works
Adding the -sSf flags to curl forces it to be silent, fail on server errors, and fail silently, which stops the pipe from sending garbage error messages into your shell. Using the dash-s flag with bash tells it to read commands from standard input while still letting you pass positional arguments after the double dash.
🚀 Pro-Tip: Always pipe to sh -n first if you’re feeling paranoid, it checks for syntax errors without actually running the code.
Linux Tips & Tricks | © ngelinux.com | 12/6/2026
