Created
July 17, 2015 17:21
-
-
Save neonichu/6231be41d4aba6f91aa3 to your computer and use it in GitHub Desktop.
Print the path to the program being executed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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