2
システム内で実行可能ファイルを実行するための迅速なスクリプトを使用しようとしています。私は2番目の答えhereを踏襲し、しかし、私は財団が適切に構築されていないことを訴えてエラーに遭遇:実行中のシステムプログラムとFoundationバグ
エラー:
/usr/lib/swift/CoreFoundation/CoreFoundation.h:25:10: note: while building module 'SwiftGlibc' imported from /usr/lib/swift/CoreFoundation/CoreFoundation.h:25:
#include <sys/types.h>
^
コード:
import Foundation
func execCommand(command: String, args: [String]) -> String {
if !command.hasPrefix("/") {
let commandFull = execCommand(command: "/usr/bin/which", args: [command]).trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
return execCommand(command: commandFull, args: args)
} else {
let proc = Process()
proc.launchPath = command
proc.arguments = args
let pipe = Pipe()
proc.standardOutput = pipe
proc.launch()
let data = pipe.fileHandleForReading.readDataToEndOfFile()
return String(data: data, encoding: String.Encoding.utf8)!
}
}
let commandOutput = executeCommand("/bin/echo", ["Hello, I am here!"])
println("Command output: \(commandOutput)")
私が使用してこれを実行していますLinuxの偽りのREPL(Archlinux)質問:それはここに不平を言っているよう
私が作った他のすべての小さなプロジェクトがうまく働いていた、財団とエラーを発見したことはありません。私のインストールは問題ですか?
Glibcを使用して実行可能ファイルを実行する簡単な方法はありますか?