From a31f018c6bc0db0de4fdf9617f75f5cf497ac273 Mon Sep 17 00:00:00 2001 From: Kare Morstol Date: Thu, 28 Aug 2014 03:15:07 +0200 Subject: [PATCH] Added access to environment variables, and new test script listallexecutablesinpath. --- SwiftShell/File.swift | 1 + SwiftShellTests/Scripts/listallexecutablesinpath.swift | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 SwiftShellTests/Scripts/listallexecutablesinpath.swift diff --git a/SwiftShell/File.swift b/SwiftShell/File.swift index 2df5d96..a441cc1 100644 --- a/SwiftShell/File.swift +++ b/SwiftShell/File.swift @@ -73,6 +73,7 @@ public func open(path: String, mode: FileMode = .Read) -> File { return file! } +public let environment = NSProcessInfo.processInfo().environment as [String: String] public let standardinput = File.fileHandleWithStandardInput() public let standardoutput = File.fileHandleWithStandardOutput() public let standarderror = File.fileHandleWithStandardError() diff --git a/SwiftShellTests/Scripts/listallexecutablesinpath.swift b/SwiftShellTests/Scripts/listallexecutablesinpath.swift new file mode 100644 index 0000000..203d1eb --- /dev/null +++ b/SwiftShellTests/Scripts/listallexecutablesinpath.swift @@ -0,0 +1,8 @@ + +import SwiftShell + +let directories = environment["PATH"]!.split(":") + +for directory in directories { + run("find \(directory) -type f -perm +ugo+x -print") |> standardoutput +}