Skip to content

Instantly share code, notes, and snippets.

@loganwright
loganwright / Shell.swift
Last active November 12, 2016 10:46
Call shell commands from Swift
func shell(input: String) -> (output: String, exitCode: Int32) {
let arguments = split(input, maxSplit: Int.max, allowEmptySlices: true) {
$0 == " "
}
let task = NSTask()
task.launchPath = "/usr/bin/env"
task.arguments = arguments
task.environment = [
"LC_ALL" : "en_US.UTF-8",
@alloy
alloy / README.markdown
Created August 8, 2014 09:56
Learn the LLVM C++ API by example.

The easiest way to start using the LLVM C++ API by example is to have LLVM generate the API usage for a given code sample. In this example it will emit the code required to rebuild the test.c sample by using LLVM:

$ clang -c -emit-llvm test.c -o test.ll
$ llc -march=cpp test.ll -o test.cpp