- Nov 30, 2023
- 2 Min Read
- CLI
How to Pass Arguments to a Remote Install Script
Disclaimer: You should avoid executing unknown scripts from the Internet. Always examine the source of the script before executing it.
One-liners are always handy. That's why it is convenient these days to install applications via a script served through HTTP:
curl https://example.com/install | bash
Often, such a call installs the latest version of the respective application. But what if you want to install a specific version of the app? First and foremost, you need to ensure that the install script accepts arguments where you can specify the version. If this is the case, that's great! But then the next question arises: How do you actually pass the argument to the command?
For instance, when using bash
, you can pass the -s
option, which is used to specify that the shell should read commands from the standard input (stdin
).
Passing arguments to the downloaded script would then look like this:
curl https://example.com/install | bash -s -- arg0 arg1
Example: Installing a Specific Version of Bun
For example, let's say we want to install a specific version of Bun. We can achieve this by passing the argument bun-v1.0.15
, which indicates the tag name of the repository. You can visit their releases page, select the version (in this case, the git tag), and pass it as an argument like this:
curl -fsSL https://bun.sh/install | bash -s -- bun-v1.0.15