diff --git a/SwiftShell/Command.swift b/SwiftShell/Command.swift index 844c373..ca3a0a5 100644 --- a/SwiftShell/Command.swift +++ b/SwiftShell/Command.swift @@ -29,7 +29,7 @@ left side as standard input. Warning: is only meant to be used with the "run" command, but could also unintentionally catch other uses of "ReadableStreamType |> ReadableStreamType", though that statement doesn't make any sense. */ -public func |> (lhs: ReadableStreamType, rhs: @autoclosure () -> ReadableStreamType) -> ReadableStreamType { +public func |> (lhs: ReadableStreamType, @autoclosure rhs: () -> ReadableStreamType) -> ReadableStreamType { assert(_nextinput_ == nil) _nextinput_ = lhs let result = rhs() @@ -49,7 +49,7 @@ public func run (shellcommand: String) -> ReadableStreamType { let task = newtask(shellcommand) if let input = _nextinput_ { - task.standardInput = input as FileHandle + task.standardInput = input as! FileHandle _nextinput_ = nil } else { // avoids implicit reading of the main script's standardInput diff --git a/SwiftShell/FileHandle.swift b/SwiftShell/FileHandle.swift index fdf372c..3b19475 100644 --- a/SwiftShell/FileHandle.swift +++ b/SwiftShell/FileHandle.swift @@ -19,7 +19,7 @@ extension FileHandle: ReadableStreamType { return nil } else { if let result = NSString(data: data, encoding: streamencoding) { - return result + return result as String } else { printErrorAndExit("Fatal error - could not read stream.") } @@ -29,7 +29,7 @@ extension FileHandle: ReadableStreamType { public func read () -> String { let data: NSData = self.readDataToEndOfFile() if let result = NSString(data: data, encoding: streamencoding) { - return result + return result as String } else { printErrorAndExit("Fatal error - could not read stream.") } @@ -114,7 +114,7 @@ public func open (forWriting path: String, overwrite: Bool = false) -> Writeable } -public let environment = NSProcessInfo.processInfo().environment as [String: String] +public let environment = NSProcessInfo.processInfo().environment as! [String: String] public let standardinput = FileHandle.fileHandleWithStandardInput() as ReadableStreamType public let standardoutput = FileHandle.fileHandleWithStandardOutput() as WriteableStreamType public let standarderror = FileHandle.fileHandleWithStandardError() as WriteableStreamType diff --git a/SwiftShell/String.swift b/SwiftShell/String.swift index 1d0a184..1c47f5b 100644 --- a/SwiftShell/String.swift +++ b/SwiftShell/String.swift @@ -33,7 +33,7 @@ extension String { } public func countOccurrencesOf (substring: String) -> Int { - return self.findAll(substring) |> toArray |> countElements + return self.findAll(substring) |> toArray |> count } /** A lazy sequence of the ranges of `findstring` in this string. */