tags:

views:

38

answers:

2

I wrote simple script test

echo hello  #<-- inside test

if I press one time enter after hello, my script will run, if I don't press - it will not, if two times I'll receive my hello and + command was not found, can somebody please explain me this behavior thanks in advance

This is not a part of the code, this is actual code

and I run it on C-Shell, via editor of Windows command:

source ./test
+2  A: 

Some points:

  • You should not ask questions tagged with both the [csh] and [bash] tags - these are completely different programs and implement completely different script programming languages

  • You should never name a script (or any other program) test, as this is the name of a built-in feature of bash

  • Post the actual code you are asking about, without annotations and show how you run it.

anon
A: 

I have tried a similar case. I wrote a script like yours, saved it using Windows Notepad (with CRLF line terminators) and run in bash with the same effect as yours in csh. The problem is bash (so csh as well) does not understand Windows' 2-byte line terminators, which are interpreted as commands, which obviously do not exist. The solution is: change your editor or configure your current editor to use unix line terminators.

You can try for example Notepad++. Remember to change the line terminators to LF.

Michał Trybus
thanks a lot, I'm working on Windows, what editor can You recommend me?
lego69
The `$> dos2unix myfile` should fix terminator issues, and no editor change will be needed.
rlb.usa
I've just added this to the answer
Michał Trybus
Must also depend on the version of bash - I just used notepad to edit a file and then used it as input to MSYS bash - it worked perfectly. I can't speak for csh, but then I can't understand why anyone would want to use csh in the first place.
anon
By the way, maybe your editor supports LF line terminators, and just needs configuration?
Michał Trybus