File tree Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/swift sh
2+
3+ import ScriptSwift // KS1019/Script.swift ~> main
4+
5+ Script ( )
6+ . stdin ( )
7+ . map { " Received input: \( $0) . Test is working. Yay. " }
8+ . stdout ( )
Original file line number Diff line number Diff line change @@ -5,7 +5,13 @@ swift sh --clean-cache
55try () {
66 expected=" $1 "
77 script=" $2 "
8- actual=" $( swift sh " $script " 2> /dev/null) "
8+ args=" $3 "
9+
10+ if [ " $args " ]; then
11+ actual=" $( echo " $args " | swift sh " $script " 2> /dev/null) "
12+ else
13+ actual=" $( swift sh " $script " 2> /dev/null) "
14+ fi
915
1016 if [ " $actual " = " $expected " ]; then
1117 echo " \xE2\x9C\x94 Success $script "
@@ -65,3 +71,5 @@ html="<!doctype html>
6571</html>"
6672
6773try " $html " " ../Examples/curl.swift"
74+
75+ try " Received input: hh. Test is working. Yay." " ../Examples/stdin.swift" " hh"
Original file line number Diff line number Diff line change @@ -22,10 +22,10 @@ public struct Script<T> {
2222 return . init( success: array. joined ( separator: " " ) )
2323 }
2424
25- public func stdin( ) -> Script < [ String ] > {
26- guard let array: [ String ] = readLine ( ) ? . split ( separator: " " ) . map ( { s in String ( s) } ) else { return . init( success: [ ] ) }
27- return . init( success: array)
28- }
25+ // public func stdin() -> Script<[String]> {
26+ // guard let array: [String] = readLine()?.split(separator: " ").map({ s in String(s) }) else { return .init(success: []) }
27+ // return .init(success: array)
28+ // }
2929
3030 public func stdout( ) {
3131 switch input {
You can’t perform that action at this time.
0 commit comments