在我的~/.bashrc文件中有两个定义:
commandA,这是更长路径的别名commandB,这是 Bash 脚本的别名我想用这两个命令处理同一个文件,所以我写了以下 Bash 脚本:
#!/bin/bash
for file in "$@"
do
commandA $file
commandB $file
done
Run Code Online (Sandbox Code Playgroud)
即使在退出会话并重新登录后,command not found当我运行此脚本时,Bash 仍会提示我输入两个命令的错误。
我究竟做错了什么?
难道set -e不同的表现在这里
set -e;
function foo {
}
Run Code Online (Sandbox Code Playgroud)
对比
function foo {
set -e;
}
Run Code Online (Sandbox Code Playgroud)
不set -e属于内部的功能呢?set -e在函数外部声明是否会影响 shell 文件中的“嵌套”函数?反过来呢?我们应该叫local set -elol吗?