「Shebang」swift スクリプトを作成しました。
を使用して入力引数を解析していますProcess.arguments
スクリプトにパイプされた場合、「パイプされた」情報をどのように読み取ることができますか?
#!/usr/bin/env xcrun swift
import Foundation
for argument in Process.arguments {
// parse the input arguments
}
// if the input is piped into the script?:
// if PIPE??? {
print("Handling pipe")
let pipe = NSPipe()
let handle = pipe.fileHandleForReading
let data = handle.readDataToEndOfFile()
print("End of pip")
}