Reputation: 41
Similar to how you can provide the -y
flag when performing a package manager update like
apt update -y
to skip any user input required to confirm the update, are you able to provide these types of option flags to arbitrary programs which require user input?
To be specific, I am creating a startup.sh
script and would like to install rust
there is a neat one-liner which you can use to do so via
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
but during the installation, the script requests the user to choose from either 3 options; 1,2, or 3, depending on which installation type you want.
how could I provide the option 1 in one command? That is, I do not want a user to be required for the installation to continue.
Edit 22/01/2025
I found a solution and thought I would add it here.
curl https://sh.rustup.rs -sSf | sh -s -- -y
does the trick.
-s
If this option is present, or if no arguments remain after option processing, then commands are read from the standard input. This option allows the positional parameters to be set when invoking an interactive shell or when reading input through a pipe.
--
signifies the end of command options, after which only positional ("non-option") arguments are accepted. see here
-y
tells the script to accept the default options.
Upvotes: -1
Views: 34