[swift-users] ProcessInfo arguments when running as a script?

Jon Shier jon at jonshier.com
Thu Aug 18 22:28:10 CDT 2016


Jordan:
	You’re quite right. I knew something had been renamed but between Process and ProcessInfo I lost my way.


Jon

> On Aug 18, 2016, at 11:05 PM, Jordan Rose <jordan_rose at apple.com> wrote:
> 
> I’d be surprised if the behavior of ProcessInfo has actually changed. Swift.CommandLine (formerly Swift.Process, unrelated to ProcessInfo) should have the script arguments only.
> 
> Jordan
> 
> 
>> On Aug 18, 2016, at 19:14, Jon Shier via swift-users <swift-users at swift.org> wrote:
>> 
>> Swift Users:
>> 	I’m trying to parse the command-line arguments of a Swift 3 script using Xcode 8 beta 6. However, ProcessInfo’s arguments array now contains all of the swift compiler arguments as well as the command itself. For example, this script:
>> 
>> #!/usr/bin/env swift
>> 
>> import Foundation
>> 
>> print(ProcessInfo.processInfo.arguments)
>> 
>> now prints:
>> 
>> ["/Users/jshier/Downloads/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift”, 
>> "-frontend”, 
>> "-interpret”, 
>> "./processInfo.swift”,
>> "-target”,
>> "x86_64-apple-macosx10.9”,
>> "-enable-objc-interop”, 
>> "-sdk”, 
>> "/Users/jshier/Downloads/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk”,
>> "-color-diagnostics”,
>> "-module-name”,
>> "processInfo"]
>> 
>> (arguments broken into lines for readability)
>> 
>> Is this a bug (and if so, does it need to be reported) or is it an intentional change (if so, how are we supposed to parse arguments now?)?
>> 
>> 
>> 
>> Jon
>> 
>> _______________________________________________
>> swift-users mailing list
>> swift-users at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-users
> 



More information about the swift-users mailing list