Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the operator </> do in FAKE build scripts?

Tags:

f#

f#-fake

I just found this target in a FAKE build script generated by ProjectScaffold:

// Copies binaries from default VS location to expected bin folder
// But keeps a subdirectory structure for each project in the
// src folder to support multiple project outputs
Target "CopyBinaries" (fun _ ->
    !! "src/**/*.??proj"
    -- "src/**/*.shproj"
    |>  Seq.map (fun f -> ((System.IO.Path.GetDirectoryName f) 
            </> "bin/Release", "bin" 
            </> (System.IO.Path.GetFileNameWithoutExtension f)))
    |>  Seq.iter (fun (fromDir, toDir) -> CopyDir toDir fromDir (fun _ -> true))
)

My question: What does this strange </> operator do?

(My internet search was not very successful.)

like image 261
Olaf Avatar asked Jan 22 '16 20:01

Olaf


1 Answers

The operator </> is an infix operator and combines two path segments into one complete path. In this aspect it is almost the same as the @@ operator. The </> operator was created after the @@ operator because the @@ operator behaves strangely on UNIX-like systems when the second path starts with root.

Here is an example taken from the issue description on GitHub.

    "src" @@ "/home/projects/something" returns "src/home/projects/something"

    "src" </> "/home/projects/something" returns "/home/projects/something"

The operator is defined in EnvironmentHelper: https://fsharp.github.io/FAKE/apidocs/fake-environmenthelper.html

These links points to the problem description: https://github.com/fsharp/FAKE/issues/670, https://github.com/fsharp/FAKE/pull/695

like image 126
Olaf Avatar answered Nov 01 '22 20:11

Olaf