相关疑难解决方法(0)

交互式shell是什么意思?

UNIX:完整参考,第二版,Kenneth H. Rosen 等人。

登录后可以使用shell的名称作为命令启动另一个shell;例如,要启动 Korn shell,您可以在命令提示符下键入 ksh。这种类型的 shell 不是登录 shell,您不必再次登录即可使用它,但它仍然是一个交互式 shell,这意味着您通过键入命令与 shell 进行交互(而不是使用 shell 来运行一个脚本,如第 20 章所述)。当您使用图形界面时,在终端窗口中运行的 shell 实例也是交互式非登录 shell。当您启动非登录 shell 时,它不会读取您的 .profile、.bash_profile 或 .login 文件(或您的 .logout 文件),但它仍会读取第二个 shell 配置文件(例如 .bashrc)。这意味着您可以测试对 .

我正在浏览以上几行,但我不明白交互式 shell 的含义。如果我使用终端,.profile 是不是真的没有被读取?

此外,当您说 bourne 不是交互式 shell 而 bash/csh 是交互式 shell 时,这意味着什么?

shell

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

直接运行命令和使用`bash -c` 有什么区别?

对于命令(内置或外部),直接在 bash shell 进程中运行它和bash -c在 bash shell中运行它有什么区别?与彼此相比,它们的优点和缺点是什么?

For example, in a bash shell, run `date` directly, and run `bash -c
date`. Also consider a builtin command instead of an external one.
Run Code Online (Sandbox Code Playgroud)

bash

11
推荐指数
3
解决办法
8704
查看次数

将命令从 cmd.exe (WSL) 传递给 bash 不起作用

我在 Windows 10 机器上,启用/配置了适用于 Linux 的 Windows 子系统 (Ubuntu)。为了解释我的问题,让我向您展示两种情况:

场景一:

  1. 我开始cmd.exe提示
  2. bashcmd.exe提示符下运行
  3. (内部bash)我运行给定的命令,dwiextract在我的情况下调用(来自神经影像分析软件包)

工作正常,表明软件包安装成功。

场景2:

  1. 我开始cmd.exe提示
  2. 我尝试使用以下语法将完全相同的命令直接传递给bashfrom cmd.exebash -c dwiextract

我明白了command not found

(注意我在bash -c 这里了解到并在其他场合成功使用了它。)

下图准确显示了我所做的:

example_diagram

我的问题:这两种情况不应该是等价的。为什么方案 1 有效而方案 2 无效?

非常感谢。

bash ubuntu windows windows-subsystem-for-linux

9
推荐指数
1
解决办法
7378
查看次数

`bash -i -c <command>` 创建的 shell 是交互式的吗?

来自https://unix.stackexchange.com/a/276611/674

bash与 一起运行时-c,它被认为是一个非交互式 shell ~/.bashrc,除非-i指定,否则它不会读取。所以,

$ type cp
cp is aliased to ‘cp -i’          # Defined in  ~/.bashrc

$ cp .file1 file2
cp: overwrite ‘file2’? n

$ bash -c "cp .file1 file2"
                                  # Existing file is overwritten without confirmation!
$ bash -c -i "cp .file1 file2"
cp: overwrite ‘file2’? n
Run Code Online (Sandbox Code Playgroud)

shell 是由bash -i -c <command>交互式还是非交互式创建的?

这样的 shell 不接受来自 stdin 的命令,是吗?所以它不是交互式的,是吗?

这样的 shell 读取~/.bashrc,所以它不能是非交互式的,对吗?

bash

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