cham-s
(Chams)
1
Hi,
I was trying to write a little script to generate a UUID using swift inside the shell.
It seems like the following snippet doesn't work
echo "import Foundation\nprint(UUID().uuidString)" | swiftc
The help output message is well documented, but since it's pretty detailed to make sure to find the right option I tried to filtered with the following lines
swiftc -h | grep "standard input"
swiftc -h | grep standard
swiftc -h | grep input
swiftc -h | grep pipe
They didn't yield the right option to use.
I was wondering what is the right option to add to read from standard input?
1 Like
allevato
(Tony Allevato)
2
Use a hyphen as the input file name to tell it to read from stdin:
echo "import Foundation\nprint(UUID().uuidString)" | swiftc -
4 Likes
al45tair
(Alastair Houghton)
3
It works with just swift as well as swiftc, FWIW:
$ echo "import Foundation\nprint(UUID().uuidString)" | swift -
A3AB5802-6AA0-47F6-914C-49FA85E02049
3 Likes
cham-s
(Chams)
4
Thanks!
Yes, stdin rather I edited it.