2013-01-24 34 views
2

我有了這樣的爲什麼定義函數時Bash會返回錯誤'ash'?

function module() { 
    .... 
} 

一個很簡單的功能我在命令提示符下鍵入「慶典」和預期的.bashrc被執行的.bashrc文件,但是我得到的錯誤:

'ash: /user/.bashrc: line 1: syntax error near unexpected token `{ 
'ash: /user/.bashrc: line 1: `function module() { 

我試過刪除單詞「功能」,我也試過刪除(),但沒有一個幫助。有人能讓我知道發生了什麼嗎?當我運行bash --version

的Bash版本(我可以升級到最新的版本,但只有模塊將讓我指出最新的bash所以這個問題在這個慶典要解決)

GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu) 
Copyright (C) 2005 Free Software Foundation, Inc. 
+2

錯誤開始「灰」或「bash」 – Vorsprung

+0

奇怪的是它只能說「灰」 –

回答

4

其實我一直在使用bash,但是.bashrc文件是在Windows中使用Windows CR保存的。一旦我運行dos2unix它工作得很好!

+3

是的,你的錯誤信息與字符覆蓋行的開始是你有'\ r \ n'的經典贈品行結束。 –

相關問題