[Swift-commit] r7551 - SwiftApps/swift-galaxy/swift

ketan at ci.uchicago.edu ketan at ci.uchicago.edu
Mon Feb 3 13:53:52 CST 2014


Author: ketan
Date: 2014-02-03 13:53:51 -0600 (Mon, 03 Feb 2014)
New Revision: 7551

Modified:
   SwiftApps/swift-galaxy/swift/swiftforeachlist.sh
Log:
prop

Modified: SwiftApps/swift-galaxy/swift/swiftforeachlist.sh
===================================================================
--- SwiftApps/swift-galaxy/swift/swiftforeachlist.sh	2014-02-03 18:54:30 UTC (rev 7550)
+++ SwiftApps/swift-galaxy/swift/swiftforeachlist.sh	2014-02-03 19:53:51 UTC (rev 7551)
@@ -15,19 +15,29 @@
 logfile=$1
 shift
 
+a=()
 while [ $# -gt 0 ] ; do
-  a="$a"" $1"
-  shift 
+  a+=("\"$1\"")
+  shift
 done
 
+#workout the array only if user adds args else make it blank
+if [ ${#a[@]} -gt 0 ] ; then
+    tmp=$(printf -- '%s,' "${a[@]}")
+    arrayexpr='string args[]=['$(echo $tmp | sed s/,$//)'];';
+else
+    arrayexpr='string args[];'
+fi
+
+
 cat << EOF > /tmp/script.swift
 type file;
 
-app (file _out, file _err) anapp(file _exec, int _i, string _args){
+app (file _out, file _err) anapp(file _exec, int _i, string _args[]){
     sh @_exec _i _args stdout=@_out stderr=@_err;
 }
+$arrayexpr
 
-string args="$a";
 file exec<"$executable">;
 file listfile<"$listfile">;
 string list[] = readData(listfile);




More information about the Swift-commit mailing list