0

我有一个库文件,其中有一个别名:

$ cat mylib.sh
alias mal='ls -l'

$cat test.sh
#!/bin/bash
source mylib.sh
mal

$./test.sh
./test.sh: line 3: mal: command not found

有什么想法吗?

4

1 回答 1

2

要在非交互式 shell 中执行别名,请使用

shopt -s expand_aliases

您可能想要使用函数:

mal() { 
    ls -l
}

mal
于 2013-02-06T18:45:09.337 回答