`lineEnding` and the clash of operating systems"

library(Orcs)

Complementing the utility of setwdOS, another tool I came to develop in the context of OS-dependent programming and, more specifically, line endings is introduced in the following. Those who have worked with numerous people on one and the same project, e.g. hosted on GitHub or Subversion, might have already grown familiar with the topic: line endings are automatically adjusted to your local OS, rendering the otherwise practical 'track changes' functionality useless. Obviously, this makes it very hard for your collaborators to understand the actual changes you made to a particular file since every single line is marked as modified.

I came to face this issue when dealing with version control on Subversion and couldn't help but develop this short code snippet in order for my collaborators to track my changes. GitHub seemingly offers a built-in option to manipulate global settings for line endings, but I haven't tried this so far. Anyway, my manual approach goes by the name lineEnding and requires

Note that the code relies on the dos2unix external software tool which can easily be installed on Linux via

sudo apt-get install dos2unix

or downloaded directly from the project website for any other OS. Once everything is set up, try the following brief example to clarify what I was trying to explain and demonstrate the usefulness of lineEnding:

## input file
infile <- file.path(system.file(package = "Orcs"), "DESCRIPTION")

system(paste("file", infile))
# > C:/Users/.../R/win-library/3.5/Orcs/DESCRIPTION: ASCII English text, with CRLF line terminators

## convert to dos line endings and write to output file
outfile = file.path(tempdir(), "DESCRIPTION4wd")
lineEnding(infile, outfile = outfile, to = "unix")

system(paste("file", outfile))
# > C:\Users\...\AppData\Local\Temp\RtmpMX3o1b/DESCRIPTION4wd: ASCII English text


Try the Orcs package in your browser

Any scripts or data that you put into this service are public.

Orcs documentation built on May 2, 2019, 2:37 a.m.