在 bash 中为 cmd 添加别名,无需编辑脚本

Alias a cmd in bash, without editing the script

考虑以下脚本

#!/bin/bash
abc

在这里,我希望将“abc”cmd 别名为 echo“Hi”(比方说)
但是我没有权限修改脚本。

有没有办法在不触及脚本的情况下改变 cmd 行为?

$ cat ./someScript.sh
#!/bin/bash
abc

$ ./someScript.sh
./someScript.sh: line 2: abc: command not found

定义一个名为 abc 的函数,并导出它。

$ abc() { echo Hi; }
$ export -f abc

现在:

$ ./someScript.sh
Hi