首页 > 解决方案 > 是否有与“-y”等效的标志用于在 bash 中选择选项?

问题描述

我正在启动要Rust在我的 macOS 上安装的脚本。命令行如下:

curl https://sh.rustup.rs -sSf | sh

我得到的是(我裁剪它):

Welcome to Rust!

This will download and install the official compiler for the Rust programming 
language, and its package manager, Cargo.

Current installation options:

   default host triple: x86_64-apple-darwin
     default toolchain: stable
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>

我必须在 1、2 和 3 之间选择一个选项。但我想在命令行中添加一个标志以始终选择一个选项,比如 2。
我正在考虑类似的东西:

curl https://sh.rustup.rs -sSf | sh -2

-y与对所有问题强制“是”相同。但这些都不起作用。

有没有办法这样做bash

标签: bashflags

解决方案


用这个:

curl https://sh.rustup.rs -sSf | sh -s -- -y

解释了命令语法。


推荐阅读