简体   繁体   中英

Why does Bash return errors with `'ash` when defining a function?

I have a .bashrc file that has a very simple function like this

function module() {
    ....
}

I type "bash" on the command prompt and as expected the .bashrc gets executed however I get the error:

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

I have tried removing the word "function" and I have also tried removing the () but none of this helps. Can someone let me know what is happening?

Bash version when I run bash --version is (I can upgrade to the latest version but ONLY the module will let me point to the latest bash so this problem has to be solved in this bash)

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

Actually I was using bash all the time but the .bashrc file was saved in Windows with the Windows CRs. Once I ran dos2unix it worked fine!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM