From p.dalgaard at biostat.ku.dk  Sun Oct 18 00:00:32 2009
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: Sun, 18 Oct 2009 00:00:32 +0200
Subject: [Rd] (PR#14012)
In-Reply-To: <20091017210301.GC1411@orange.local>
References: <20091016130010.3717A282EFF1@mail.pubhealth.ku.dk>
	<20091017210301.GC1411@orange.local>
Message-ID: <4ADA3E80.6010109@biostat.ku.dk>

Seth Falcon wrote:
> * On 2009-10-16 at 15:00 +0200 sje30 at damtp.cam.ac.uk wrote:
>> I think Rscript has a problem running files that have mac encodings
>> for newline (^M rather than ^J on linux).  If I source the file within
>> R, it works okay:
> 
>>> source('j.R')
>> [1] "MEA_data/sernagor_new/CRX_P7_1.txt"
>>
>> But if I run the file using Rscript on a linux box I get a strange
>> error message: 
>>
>> $ Rscript --vanilla j.R
>> "
>> Execution halted
> 
> I think you are right that Rscript is unhappy to handle files with CR
> line terminators.  But IIUC, the purpose of Rscript is to enable R
> script execution on unix-like systems like:
> 
>    #!/path/to/Rscript --vanilla
>    print(1:10)
> 
> So then I'm not sure how useful it is for Rscript to handle such
> files.  Why not convert to a more common and portable line termination
> for your R script files?

Notice also that other script interpreters aren't happy about CR line 
endings:

$ cat > x.sh
#!/bin/bash
echo hello

Now change the LF to CR and get

$ ./x.sh
bash: ./x.sh: /bin/bash^M: bad interpreter: No such file or directory

or (if you add a space)

$ ./x.sh
  echo hello: No such file or directory

$ bash -v ./x.sh
  echo hello

(overprinting is involved in the last one).

-- 
    O__  ---- Peter Dalgaard             ?ster Farimagsgade 5, Entr.B
   c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907



[Rd] (PR#14012)
Peter Dalgaard