From 32d68a329d613882ad3e76c45732f4d1ed3e82f4 Mon Sep 17 00:00:00 2001 From: Kare Morstol Date: Thu, 17 Sep 2015 01:36:23 +0200 Subject: [PATCH] Fix bug in main.arguments Process.arguments is never empty as the first item is always the path of the script. Except for in a playground where it actually is empty. --- SwiftShell/Context.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SwiftShell/Context.swift b/SwiftShell/Context.swift index 2755b7a..ae4cb95 100644 --- a/SwiftShell/Context.swift +++ b/SwiftShell/Context.swift @@ -52,7 +52,8 @@ public final class MainShellContext: ShellContextType { } } - public lazy var arguments: [String] = Process.arguments.isEmpty ? [] : Array(Process.arguments.dropFirst()) + + 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 ?? "" private init() {