小编che*_*rov的帖子

在 bash 脚本中实现批处理选项 --yes

我有几个用户输入语句,例如:

read -r -p "Do u want to include this step (y) or not (n) (y/N)"? answer
if [[ "$answer" =~ ^[Yy]$ ]]; then 
    ...
fi
Run Code Online (Sandbox Code Playgroud)

我正在寻找一种方法来自动对所有这些问题回答“是”。想象一个非交互式会话,其中用户使用--yes选项调用脚本。没有进一步的stdin输入。

我现在能想到的唯一方法是在每个if 语句上添加另一个条件。

有什么想法吗?

bash shell-script

5
推荐指数
3
解决办法
778
查看次数

尝试安装 debian 包 npm,使 apt-get 删除 libssl-dev

:~/$ uname -a
Linux hostname 4.9.0-4-rt-amd64 #1 SMP PREEMPT RT Debian 4.9.51-1 (2017-09-28) x86_64 GNU/Linux
Run Code Online (Sandbox Code Playgroud)

我认为我有一个清晰的依赖树,没有损坏的包。

:~/$ sudo apt-get check
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试安装时npm,apt-get 想要删除libssl-dev

:~$ sudo apt-get install npm
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libldns2 libssl-doc
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed: …
Run Code Online (Sandbox Code Playgroud)

debian apt ssl npm

4
推荐指数
1
解决办法
2811
查看次数

标签 统计

apt ×1

bash ×1

debian ×1

npm ×1

shell-script ×1

ssl ×1