[Swift-commit] r7609 - SwiftApps/swift-galaxy/swift
ketan at ci.uchicago.edu
ketan at ci.uchicago.edu
Wed Feb 19 13:14:05 CST 2014
Author: ketan
Date: 2014-02-19 13:14:04 -0600 (Wed, 19 Feb 2014)
New Revision: 7609
Modified:
SwiftApps/swift-galaxy/swift/swiftforeach.xml
SwiftApps/swift-galaxy/swift/swiftforeachlist.sh
SwiftApps/swift-galaxy/swift/swiftforeachrange.sh
Log:
simplify string args
Modified: SwiftApps/swift-galaxy/swift/swiftforeach.xml
===================================================================
--- SwiftApps/swift-galaxy/swift/swiftforeach.xml 2014-02-18 05:37:04 UTC (rev 7608)
+++ SwiftApps/swift-galaxy/swift/swiftforeach.xml 2014-02-19 19:14:04 UTC (rev 7609)
@@ -23,9 +23,7 @@
"${outloc}"
"${logfile}"
"${outlist}"
- #for $a in $stringarg
- ${a.stringargname}
- #end for
+ "${stringargs}"
#for $a in $filearg
${a.fileargname}
#end for
@@ -38,9 +36,7 @@
"${outloc}"
"${logfile}"
"${outlist}"
- #for $a in $stringarg
- ${a.stringargname}
- #end for
+ "${stringargs}"
#for $a in $filearg
${a.fileargname}
#end for
@@ -56,9 +52,7 @@
"${outloc}"
"${logfile}"
"${outlist}"
- #for $a in $stringarg
- ${a.stringargname}
- #end for
+ "${stringargs}"
#for $a in $filearg
${a.fileargname}
#end for
@@ -117,9 +111,7 @@
</conditional>
- <repeat name="stringarg" title="string arg">
- <param name="stringargname" type="text" label="stringarg" />
- </repeat>
+ <param name="stringargs" type="text" label="stringarg" />
<repeat name="filearg" title="file arg">
<param name="fileargname" type="data" label="filearg" />
Modified: SwiftApps/swift-galaxy/swift/swiftforeachlist.sh
===================================================================
--- SwiftApps/swift-galaxy/swift/swiftforeachlist.sh 2014-02-18 05:37:04 UTC (rev 7608)
+++ SwiftApps/swift-galaxy/swift/swiftforeachlist.sh 2014-02-19 19:14:04 UTC (rev 7609)
@@ -18,16 +18,11 @@
logfile=$1
shift
-stringargs=()
-while [ $# -gt 0 ] ; do
- stringargs+=("\"$1\"")
- shift
-done
+stringargs=$1
#workout the array only if user adds args else make it blank
-if [ ${#stringargs[@]} -gt 0 ] ; then
- tmp=$(printf -- '%s,' "${stringargs[@]}")
- stringarrayexpr='string stringargs[]=['$(echo $tmp | sed s/,$//)'];';
+if [ "${stringargs}" ] ; then
+ stringarrayexpr='string stringargs[]=['$(echo $stringargs | sed -e 's/ *$//g' -e 's/[^ ][^ ]*/"&"/g' -e 's/ /,/g')'];';
else
stringarrayexpr='string stringargs[];'
fi
Modified: SwiftApps/swift-galaxy/swift/swiftforeachrange.sh
===================================================================
--- SwiftApps/swift-galaxy/swift/swiftforeachrange.sh 2014-02-18 05:37:04 UTC (rev 7608)
+++ SwiftApps/swift-galaxy/swift/swiftforeachrange.sh 2014-02-19 19:14:04 UTC (rev 7609)
@@ -23,23 +23,11 @@
logfile=$1
shift
-stringargs=()
-while [ $# -gt 0 ] ; do
- stringargs+=("\"$1\"")
- shift
-done
+stringargs=$1
#workout the array only if user adds args else make it blank
-stringargs=()
-while [ $# -gt 0 ] ; do
- stringargs+=("\"$1\"")
- shift
-done
-
-#workout the array only if user adds args else make it blank
-if [ ${#stringargs[@]} -gt 0 ] ; then
- tmp=$(printf -- '%s,' "${stringargs[@]}")
- stringarrayexpr='string stringargs[]=['$(echo $tmp | sed s/,$//)'];';
+if [ "${stringargs}" ] ; then
+ stringarrayexpr='string stringargs[]=['$(echo $stringargs | sed -e 's/ *$//g' -e 's/[^ ][^ ]*/"&"/g' -e 's/ /,/g')'];';
else
stringarrayexpr='string stringargs[];'
fi
More information about the Swift-commit
mailing list