开发者

strange behavior

开发者 https://www.devze.com 2023-01-01 10:12 出处:网络
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 pr开发者_Python百科ess - it will not, if two times I\'ll receive my h

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 pr开发者_Python百科ess - 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


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消