2013-02-06 30 views
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 

有什麼想法?

+1

別名通常不會擴展到非交互shell –

回答

2

要在非交互的shell執行一個別名,使用

shopt -s expand_aliases 

你可能反而要使用的功能:

mal() { 
    ls -l 
} 

mal 
+0

對不起它是錯字!讓我解決它。 – Amir

+0

它後面有一個別名 – Amir

+0

如果可能,我不想將它用作函數... – Amir