Skip to content

Instantly share code, notes, and snippets.

@neonichu
Created July 17, 2015 17:21
Show Gist options
  • Save neonichu/6231be41d4aba6f91aa3 to your computer and use it in GitHub Desktop.
Save neonichu/6231be41d4aba6f91aa3 to your computer and use it in GitHub Desktop.
Print the path to the program being executed
#!/usr/bin/env swift
import Foundation
var path = (Process.arguments[0] as NSString)
path = path.stringByDeletingLastPathComponent
path = String(CString:realpath(path.cStringUsingEncoding(NSUTF8StringEncoding), nil),
encoding: NSUTF8StringEncoding)!
print("\(path) \n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment