Using Swift for interpreted shell scripts?

Are there any resources on using swift for shell scripting?

I’m interested in trying my hand at Swift by converting existing bash scripts into swift since bash is mostly what I am writing currently, so I figure this will at least get me started with syntax and such.

ZZ

···

--
The Steve is seen, rightly or wrongly, as the visionary, the leader,
the savant. Bill is the Boswell to The Steve's Johnson, but lacking
Boswell's wit, charm, and dynamic personality.

Swift doesn’t seem like a good fit for the kinds of tasks people write shell-scripts for. It’s a system/app programming language, like C/C++. Scripting languages have extremely dynamic typing, super-high-level APIs, and no separate compile/link stage.

There’s no reason you couldn’t convert some shellscripts as an exercise to learn Swift, but I don’t think you’ll find many resources out there.

—Jens

I've given up on it. I find it far easier to just write a command-line app with Xcode's source support -- E

···

On Dec 15, 2015, at 12:45 PM, @lbutlr via swift-users <swift-users@swift.org> wrote:

Are there any resources on using swift for shell scripting?

I’m interested in trying my hand at Swift by converting existing bash scripts into swift since bash is mostly what I am writing currently, so I figure this will at least get me started with syntax and such.

ZZ

One possible advantage is that it would be relatively easy (instead of nigh-impossible) to have a shell script that interacts efficiently with the GUI.

But yes, this is mostly meant as a way for me to get a handle on the language by writing things I am familiar with and have some investment in.

···

On Dec 15, 2015, at 1:28 PM, Jens Alfke <jens@mooseyard.com> wrote:

Swift doesn’t seem like a good fit for the kinds of tasks people write shell-scripts for. It’s a system/app programming language, like C/C++. Scripting languages have extremely dynamic typing, super-high-level APIs, and no separate compile/link stage.

--
Stone circles were common enough everywhere in the mountains. Druids
built them as weather computers, and since it was always cheaper to
build a new 33-Megalith circle than to upgrade an old slow one, there
were generally plenty of ancient ones around --Lords and Ladies

Check out this talk from Ayaka on just this topic! Swift Scripting

···

On Dec 15, 2015, at 12:37 PM, @lbutlr via swift-users <swift-users@swift.org> wrote:

On Dec 15, 2015, at 1:28 PM, Jens Alfke <jens@mooseyard.com> wrote:
Swift doesn’t seem like a good fit for the kinds of tasks people write shell-scripts for. It’s a system/app programming language, like C/C++. Scripting languages have extremely dynamic typing, super-high-level APIs, and no separate compile/link stage.

One possible advantage is that it would be relatively easy (instead of nigh-impossible) to have a shell script that interacts efficiently with the GUI.

But yes, this is mostly meant as a way for me to get a handle on the language by writing things I am familiar with and have some investment in.

--
Stone circles were common enough everywhere in the mountains. Druids
built them as weather computers, and since it was always cheaper to
build a new 33-Megalith circle than to upgrade an old slow one, there
were generally plenty of ancient ones around --Lords and Ladies

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Check out this talk from Ayaka on just this topic! Swift Scripting

Thank you, that looks very promising.

I didn’t realize the list was set to “reply off list” so a message I thought I posted didn’t go through. Rather than repost it…

···

On 15 Dec 2015, at 14:12, John Regner <regnerjr@gmail.com> wrote:

On Dec 15, 2015, at 12:59 PM, David Turnbull <dturnbull@gmail.com> wrote:

There's this shebang for OS X:
#!/usr/bin/env xcrun swift

Interesting. I was just messing around with

#!/usr/bin/swift

And making some (albeit slow) progress.

===

Is there a reason to use xcrun instead of calling swift directly?

--
'But you ain't part of it, are you?' said Granny conversationally. 'You
try, but you always find yourself watchin' yourself watchin' people, eh?
Never quite believin' anything? Thinkin' the wrong thoughts?'

I write my scripts in a Playground to get autocompletion and instant feedback. Kind of works but sometimes I wish Playgrounds would start faster with running. And sometimes they stop working and I have to restart Xcode.

···

On 15.12.2015, at 20:57, Erica Sadun via swift-users <swift-users@swift.org> wrote:

I've given up on it. I find it far easier to just write a command-line app with Xcode's source support -- E

On Dec 15, 2015, at 12:45 PM, @lbutlr via swift-users <swift-users@swift.org> wrote:

Are there any resources on using swift for shell scripting?

I’m interested in trying my hand at Swift by converting existing bash scripts into swift since bash is mostly what I am writing currently, so I figure this will at least get me started with syntax and such.

ZZ

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Check out this talk from Ayaka on just this topic! Swift Scripting

Thank you, that looks very promising.

I didn’t realize the list was set to “reply off list” so a message I thought I posted didn’t go through. Rather than repost it…

There's this shebang for OS X:
#!/usr/bin/env xcrun swift

Interesting. I was just messing around with

#!/usr/bin/swift

And making some (albeit slow) progress.

===

Is there a reason to use xcrun instead of calling swift directly?

Probably not. You can just call `swift` and it will shim through to the same thing as `xcrun swift`.

IIRC, 10.9 didn't have the `swift` shim, but every OS X release since then has.

- Daniel

···

On Dec 16, 2015, at 7:21 AM, @lbutlr via swift-users <swift-users@swift.org> wrote:
On 15 Dec 2015, at 14:12, John Regner <regnerjr@gmail.com> wrote:
On Dec 15, 2015, at 12:59 PM, David Turnbull <dturnbull@gmail.com> wrote:

--
'But you ain't part of it, are you?' said Granny conversationally. 'You
try, but you always find yourself watchin' yourself watchin' people, eh?
Never quite believin' anything? Thinkin' the wrong thoughts?'

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users