Exchange main.name with main.path.
This commit is contained in:
@@ -117,7 +117,9 @@ public final class MainShellContext: ShellContextType {
|
||||
public lazy var tempdirectory: String = createTempdirectory()
|
||||
|
||||
public lazy var arguments: [String] = Process.arguments.count <= 1 ? [] : Array(Process.arguments.dropFirst())
|
||||
public lazy var name: String = Process.arguments.first.map(NSURL.init)?.lastPathComponent ?? ""
|
||||
|
||||
/** The path to the currently running executable. Will be empty in playgrounds. */
|
||||
public lazy var path: String = Process.arguments.first ?? ""
|
||||
|
||||
private init() {
|
||||
}
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
import SwiftShell
|
||||
|
||||
print(main.name, main.arguments.map {"\""+($0)+"\""} .joinWithSeparator(" "))
|
||||
print(NSURL(fileURLWithPath: main.path).lastPathComponent!, main.arguments.map {"\""+($0)+"\""} .joinWithSeparator(" "))
|
||||
|
||||
@@ -21,9 +21,9 @@ export SWIFTSHELL_FRAMEWORK_PATH=$PROJECT_ROOT/build/Release/
|
||||
|
||||
assert "./print_name_and_args.swift 1 2" "print_name_and_args.swift \"1\" \"2\""
|
||||
assert_raises "./exitswhenopeningnon-existentfile.swift" 132
|
||||
assert "cat onetwothree.txt | ./print_linenumbers.swift" "line 1: one\nline 2: two\nline 3: three"
|
||||
assert "cat onetwothree.txt | ./print_linenumbers.swift" "1: one\n2: two\n3: three"
|
||||
assert "./stream_out.swift" " 3"
|
||||
assert "./callswiftscriptfromswift.swift" "line 1: one\nline 2: two\nline 3: three"
|
||||
assert "./callswiftscriptfromswift.swift" "1: one\n2: two\n3: three"
|
||||
assert "./readfilelinebyline.swift" "one\ntwo\nthree"
|
||||
assert_raises "./readandwritefiles.swift" 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user