[Swift-commit] r7783 - in SwiftTutorials/swift-cloud-tutorial: . doc

wozniak at ci.uchicago.edu wozniak at ci.uchicago.edu
Mon Apr 21 15:11:24 CDT 2014


Author: wozniak
Date: 2014-04-21 15:11:24 -0500 (Mon, 21 Apr 2014)
New Revision: 7783

Modified:
   SwiftTutorials/swift-cloud-tutorial/doc/TODO
   SwiftTutorials/swift-cloud-tutorial/setup.sh
Log:
Support ZSH


Modified: SwiftTutorials/swift-cloud-tutorial/doc/TODO
===================================================================
--- SwiftTutorials/swift-cloud-tutorial/doc/TODO	2014-04-19 19:30:28 UTC (rev 7782)
+++ SwiftTutorials/swift-cloud-tutorial/doc/TODO	2014-04-21 20:11:24 UTC (rev 7783)
@@ -77,6 +77,7 @@
  
 3. support for zsh, csh
 [pending]
+ZSH is done. -Justin
  
 4. What results are created and where did the outputs go ?
 and pointers to what the log files mean

Modified: SwiftTutorials/swift-cloud-tutorial/setup.sh
===================================================================
--- SwiftTutorials/swift-cloud-tutorial/setup.sh	2014-04-19 19:30:28 UTC (rev 7782)
+++ SwiftTutorials/swift-cloud-tutorial/setup.sh	2014-04-21 20:11:24 UTC (rev 7783)
@@ -1,16 +1,28 @@
 # ensure that this script is being sourced
-if [ ${BASH_VERSINFO[0]} -gt 2 -a "${BASH_SOURCE[0]}" = "${0}" ] ; then
-  echo ERROR: script ${BASH_SOURCE[0]} must be executed as: source ${BASH_SOURCE[0]}
-  exit 1
+
+if [[ $0 =~ .*bash ]] ; then 
+# Bash: 
+  if [ ${BASH_VERSINFO[0]} -gt 2 -a "${BASH_SOURCE[0]}" = "${0}" ] ; then
+    echo ERROR: script ${BASH_SOURCE[0]} must be executed as: source ${BASH_SOURCE[0]}
+    exit 1
+  fi
+  # Lookup tutorial directory based on PATH entry for this script
+  TUTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 fi
+if [[ $ZSH_VERSION != "" ]] ; then 
+  # ZSH: 
+  if [[  ! $- =~ .*i.* ]] ; then 
+    echo ERROR: script $0 must be executed as: source $0
+    return 1
+  fi
+  # Lookup tutorial directory based on PATH entry for this script
+  TUTDIR="$( cd "$( dirname "$0" )" && /bin/pwd )"
+fi
 
 echo Swift version is $(swift -version)
 rm -f swift.log
 
-# Setting scripts folder to the PATH env var.
-TUTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-
-if [ _$(which cleanup 2>/dev/null) != _$TUTDIR/bin/cleanup ]; then
+if [ _$(env which cleanup 2>/dev/null) != _$TUTDIR/bin/cleanup ]; then
   echo Adding $TUTDIR/bin:$TUTDIR/app: to front of PATH
   PATH=$TUTDIR/bin:$TUTDIR/app:$PATH
 else
@@ -56,4 +68,3 @@
 cd ..
 
 return
-




More information about the Swift-commit mailing list