curl | sh truncation guard

curl | sh executes the stream as it arrives, so a dropped connection runs half a script. Fix (used by rustup and Homebrew): put everything in one function, called on the last line. A truncated download defines a broken function, hits a syntax error, and executes nothing.

main() {
...entire script...
}
main "$@"

Function definitions and variable assignments can stay top-level; they have no side effects if the tail is missing.

esc