Problem you are trying to solve
#!/bin/bash
curl https://sh.rustup.rs -sSf | sh -s -- -y
source "$HOME/.cargo/env"
cargo check
running the script says: sh: 3: cargo: not found
Although we can mannually cun source "$HOME/.cargo/env"
i will work.
but its not good for script automation . such as set up a new dev machine require as a single script.
Solution you'd like
by exec curl https://sh.rustup.rs -sSf | sh -s -- -y
and source "$HOME/.cargo/env"
inside script
cargo should work inside a bash script session.
Notes
No response