#!/usr/bin/env bash
# v0.1 iterate through my fossils.
# v0.2 Add in some git projects.
# v0.3 Added in some more sqlite-related items.
# v0.3a TODO: split this up like fossilweb.sh.
# v0.4 still working on new fossilstuff function - not live yet.
# v0.5 newfossilstuff got the axe. I've got to build a function to
#      cycle through $1.
# v0.6 I added tips to Tcl (Tcl Improvement Proposals).
# v0.6a Added extra line between downloads.
# v0.7 add libfossil, correct mistakes.
# v0.8 create a rarely section for docsrc, book and others.
# v0.9 Added sqlite-wasm to the rarely section, also added althttpd.
# v0.10 Moved sqlite-wasm back out of rarely, due to activity.
# v0.11 Added pikchr into rarely.
# v0.12 Adding params to fossil.
# v0.13 Changed out MYHOME and other vars to FOSHOME etc.
# v0.14 Added sqlite-cloudsqlite, tidied up help.
# v0.15 Put in fnc, should have been in there a while. Poor thing.
# v0.16 Added in pikmojicon, pretty rarely used.
# v0.17 Added in inskinerator, makes skins for fossil.
# v0.18 Made note about veryrarely (created for chisel project files and the like).
# v0.19 Shifted help strings for althttpd and wasm back to sqlite/ and added wapp to tcl.
# v0.20 Added wapp to rarely after cursory examination.
# v0.21 Added REAMDE, no changes to this source as a result.
# v0.22 Added LICENCE, no changes to this source as a result.
# v0.23 Tweaked help, correcting the references to chisel.
# v0.24 Silenced pushd/popd.
# v0.25 Adding "common" to cover {fossil,sqlite}-{code,forum} and tcl/tk.
# v0.26 Fixes to above for some mistakes with cd.
# v0.27 Finally removed libfossil-forum, as forum has been merged into libfossil repo.
# v0.28 Reworked hashbang for portability reasons. Added version and function.
# v0.29 Shortened up the $0, making it into a var and shortening it.
# v0.30 Reworked the help display, removed redundancies.
# v0.31 Added a fossilcommit utility function. (No functional changes to fossilsource)
# v0.32 Added sync command. Only works for fossils you can push to.
# v0.33 Added fossilsource repo.
# v0.34 Added jimtcl. This isn't always kept up to the same place as the git repo.
# v0.35 Added bash completion script. No functional change to fossilsource itself.
# v0.36 Add --verbose switch. Can't use "-v" as it's already used for "version".
# v0.37 Add tclconfig and tea(ish) projects.
# v0.38 Added c-pp and LuaSQLite projects, and added that to rarely.
# v0.39 Added '-s' and '-u' into the help. Previously not mentioned.
# v0.40 Added System.Data.SQLite (sds).
# v0.41 Fixes to rarely and veryrarely.
# v0.42 Added forums, as I use that a bit.
# v0.43 Added libwhut.
# v0.44 Removed jimtcl, he uses github and dropped fossil.
# v0.45 Added jaccwabyt, sewal, whuuid, th1-sgb and cssminc.

FOSVERSION=0.45

########
# Notes #
#########
# This really needs to be run from the source directory first.
# fossil has source code, forums, pikchr and a book.
# sqlite has source code, forums, docsrc, althttpd, wasm and a testing harness.
# tcl and tk each have source code, and tcl has proposals (tcl-tip).
# libfossil has a number of little projects related to fossil or sqlite3.
# leave libfossil out of the main loop, but call them specifically, just like fossil-book, pikchr, sqlite-wasm and sqlite-testing.
# Cannot get TH3 source without a commercial licence, so can't run tests for docsrc.
FOSHOME="${HOME}/src/c/"

# Doesn't fit, but it's short.
ME="$(basename ${0})"
# Obligatory help function
function dohelp() { # needed renaming, as "help" already exists somewhere else
  echo "Welcome to the $ME help page for version ${FOSVERSION}."
  echo "${ME} {all}: fetches all fossil, all sqlite, all tcl except rarely/veryrarely."
  echo "   -h|help|--help: this help page."
  echo "   -s: sync - needs remote permission."
  echo "   -u: synchronise /uv data (unversioned files)."
  echo "   -v|version|--version: provides version of this program."
  echo "   common: fetches {fossil,sqlite}-{code,forum}, althttpd and tcl/tk."
  echo "It leaves out things in rarely/veryrarely,"
  echo "plus a few less-updated parts of sqlite/fossil-space"
  echo "### fossil stuff."
  echo "   fossil-[code|forum|book]: fetches named section."
  echo "   fossil: fetches code and forum."
  echo "### wanderinghorse stuff."
  echo "   libfossil{-all}: fetches libfossil (libfossil-code) and fnc."
  echo "   [fsl|fnc|pikchr|pikmojicon]: fetches fsl, pikchr, pikmojicon or fnc."
  echo "   teaish: fetches the tea(ish) spinoff project."
  echo "   c-pp: c-minus pre-processor."
  echo "   jaccwabyt: JS lib for bindings between JS and C structs via WebAssembly."
  echo "   whut|libwhut: utility toolkit."
  echo "   sewal: Scripting Engine Without a Language."
  echo "   whuuid: C98 utility library to generate UUID-like strings."
  echo "   th1-sgb: Stephan's fork of th1 scripting language."
  echo "   cssminc: C98 javascript minifier."
  echo "### sqlite stuff."
  echo "   sqlite: fetches sqlite fossils (code, forum, docsrc, wasm, althttpd)."
  echo "   sqlite-{code|forum|docsrc|tests|althttpd|sds|wasm|cloud|lua}, fetches:"
  echo "       sqlite code, forum, docsrc, sds, wasm, althttpd, cloud, lua or test scripts."
  echo "   althttpd: fetches althttpd code."
  echo "   docsrc: fetches sqlite-docsrc code."
  echo "   sds: fetches System.Data.SQLite code"
  echo "   wasm: fetches wasm-related code."
  echo "### forum stuff (may need expanding if more are added)"
  echo "    forum|forums: grabs forum-related fossils."
  echo "### tcl/tk."
  echo "    tcl-code: fetches code."
  echo "    tcl-tip: fetches proposals."
  echo "    tk-code: fetches code."
  echo "    tclconfig: fetches code for tclconfig."
#  echo "### jimtcl."
#  echo "    jimtcl: fetches jimtcl fossil. Not always up to date."
  echo "### tangentsoft projects."
  echo "    inskin: fetches inskinerator code."
  echo "    tangentsoft-fossil: fetches local fossil for tangentsoft."
  echo "### Flying-brick project."
  echo "    fossilsource: fetches this codebase for this script"
  echo "### chisel project."
  echo "    flint: fetches the flint code for chisel server."
  echo "=== Rarely-updated stuff."
  echo "    rarely: updates almost all the stuff not touched by [{fossil|sqlite|libfossil}-]all."
  echo "Currently, this includes the following fossil, lifossil and sqlite projects:"
  echo "      fossil-book, pikchr, pikmojicon, fsl, sqlite-tests, sqlite-cloud, sqlite-lua, cwal,"
  echo "      sewal, whuuid, th1-sgb and cssminc."
  echo "Also includes tangentsoft's inskinerator."
  echo "This list will need modifying on occasion."
  echo "=== Very rarely updated stuff (less than yearly)."
  echo "   veryrarely: includes the flint, fuel and fsl projects."
  echo "======= TODO."
  echo "   remove inskinerator from rarely if project updates regularly."
  echo "For more projects (that vary in update frequency), check the chisel"
  echo "hosting site at chiselapp.com."
# Need a section in here for pull
  exit 0
}

function doversion() {
  echo "$ME version: ${FOSVERSION}"
  # This should really check we even _have_ a fossil first.
  echo "fossil version: $(fossil version)"
  exit 0
}
##### fossil-scm and related stuff, these presume we start from ${FOSHOME}
function fossil-code() {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} fossil.fossil
  echo "==== fossil-code...done ==="
}

function fossil-forum() {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} fossilforum.fossil
  echo "==== fossil-forum...done ==="
}

# Rarely updated
function fossil-book() {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} fossil-book.fossil
  echo "==== fossil-book...done ==="
}

function fossil-all() { # Excludes fossil-book and pikchr
  cd fossil-scm # Yes, the directory name has -scm appended
  t=fossil
  ${t}-code
  sleep 5
  ${t}-forum
  cd ..
}

###### wanderinghorse items
function libfossil-code() {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} libfossil.fossil
  echo "==== libfossil...done ==="
}

# Commented out for now (removal soon), as forums have been merged to master
# https://fossil.wanderinghorse.net/r/libfossil/forumpost/c58421800f
# function libfossil-forum {
#  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} libfossil-forum.fossil
#  echo "==== libfossil-forum...done ==="
# }

# ncurses client for fossil
function fnc {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} fnc.fossil
  echo "==== fnc...done ==="
}

# Jaccwabyt - rarely updated
function jaccwabyt {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} jaccwabyt.fossil
  echo "==== jaccwabyt...done ==="
}

# Rarely updated
function pikchr() {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} pikchr.fossil
  echo "==== pikchr...done ===="
}

# Rarely updated
function pikmojicon() {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} pikmojicon.fossil
  echo "==== pikmojicon...done ===="
}

function libfossil-all {
  cd libfossil
  libfossil-code
  sleep 2
#  libfossil-forum
  fnc
  sleep 2
  teaish  # may get moved to rarely
  sleep 2
  whut
  sleep 2
  jaccwabyt
  cd -
}

# Scripting engine without a language. Not sure where to put this.
function cwal {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} cwal.fossil
  echo "==== cwal...done ==="
}

# cson - old, but seemingly still in use
function cson {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} cson.fossil
  echo "==== cson...done ==="
}

# rough remake of tclconfig from the tcl project mentioned elsewhere
function teaish {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} teaish.fossil
  echo "==== teaish...done ==="
}

function c-pp {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} c-pp.fossil
  echo "==== c-pp...done ==="
}

function whut {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} libwhut.fossil
    echo "==== libwhut...done ==="
}

function whuuid {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} whuuid.fossil
    echo "==== whuuid...done ==="
}

function sewal {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} sewal.fossil
    echo "==== sewal...done ==="
}

function cssminc {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} cssminc.fossil
    echo "==== cssminc...done ==="
}

function th1-sgb {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} th1-sgb.fossil
    echo "==== th1-sgb...done ==="
}

###### end of wanderinghorse stuff

#### Some non-fossil-project (but fossil-related) ####
# Shell-based front end to fossil, append to rarely. Hasn't been updated since 2019.
function fsl {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} fsl.fossil
  echo "==== fsl...done ==="
}

# This is spectacularly unlikely to update further, but is here for completeness' sake
function fuel {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} fossil-fuel.fossil
  echo "==== fuel...done ==="
}

function flint {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} flint.fossil
  echo "==== flint...done ==="
}

function fresh {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} Fresh.fossil
  echo "==== fresh...done ==="
}

function inskin { # Shortened from Inskinerator
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} inskinerator.fossil
  echo "==== Inskinerator...done ==="
}

function tangentsoft-fossil() {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} tangentsoft.fossil
}

# And of course, my own pet project, fossilsource. Needs renaming so I don't
# trip over my own bash script.
function fossilsource-code() {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} fossil-bvscripts.fossil
  echo "==== fossilsource...done ==="
}

##### sqlite-hosted or sqlite-related projects
function sqlite-code() {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} sqlite.fossil
  echo "==== sqlite-code...done ==="
}

function sqlite-forum() {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} sqliteforum.fossil
  echo "==== sqlite-forum...done ==="
}

function sqlite-wasm() {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} wasm.fossil
  echo "==== sqlite-wasm...done ==="
}

function sqlite-docsrc() {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} docsrc.fossil
  echo "==== sqlite-docsrc...done ==="
}

function sqlite-althttpd() {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} althttpd.fossil
  echo "==== sqlite-althttpd...done ==="
}

### These fossils are rarely updated. ###
function sqlite-tests() {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} sqllogictest.fossil
  echo "==== sqlite-tests...done ==="
}

function sqlite-cloud() {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} cloudsqlite.fossil
  echo "==== sqlite-cloudsqlite...done ==="
}

function sqlite-lua() {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} lua.fossil
  echo "==== sqlite-lua...done ==="
}

# fetches System.Data.SQLite
function sqlite-sds() {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} sds.fossil
  echo "==== System.Data.SQLite (sds)...done ==="
}

# Does everything not in "rarely" section, presumes we're in ${FOSHOME}
function sqlite-all() {
  t="sqlite"
  cd ${t}
  ${t}-code
  sleep 5
  ${t}-forum
  sleep 5
  ${t}-docsrc
  sleep 5
  ${t}-wasm
  sleep 5
  ${t}-althttpd # shifted from rarely()
#  ${t}-tests # shifted to rarely()
#  ${t}-cloud # shifted to rarely()
  ${t}-sds
  unset $t
  cd .. # gets us back to ${MYHOME}
}

# Updates tcl sourcecode
function tcl-code() {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} tcl.fossil
  echo "==== tcl-code...done ==="
}

# Updates tcl TIP database
function tcl-tips() {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} tips.fossil
  echo "==== tcl-tips...done ==="
}

function wapp() {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} wapp.fossil
  echo "==== wapp...done ==="
}

# Updates tk sourcecode
function tk-code() {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} tk.fossil
  echo "==== tk code...done ==="
}

# helps to configure TCL extensions for compiling
function tclconfig() {
  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} tclconfig.fossil
  echo "==== tclconfig...done ==="
}

# Updates both tcl and tk sources
function tcl-all() {
  cd tcl
  tcl-code
  sleep 5
  tcl-tips   # TCL Improvement Proposals, rarely updated
  sleep 5
  wapp
  sleep 5
  tclconfig  # may put into rarely
  sleep 5
  cd ../tk
  tk-code
  cd .. # gets us back to ${MYHOME}
}

# Updates jimtcl's fossil - now canceled - he went to git.
# function jimtcl() {
#  fossil ${FOSCMD} ${FOSCMDPARAMS[*]} jimtcl.fossil
#  echo "==== jimtcl code...done ==="
# }


# these don't get updated very often, if at all
function rarely() {
# fossil stuff
  cd fossil-scm
  fossil-book
  cd -
# sqlite stuff
  cd sqlite
  sqlite-tests
  sqlite-cloud
  cd -
# wanderinghorse - a.k.a. libfossil
  cd libfossil
  cwal
  pikchr
  whuuid
  sewal
  cssminc
  th1-sgb
  cd -
  # fsl and pikmojicon moved to veryrarely
# other stuff
#  cd ../Fresh #Commented out as I don't get this any more
#  fresh
#  cd ..
  cd /h3/viking/src/c/sqlite
  sqlite-lua
  cd -  # should return to ${HOME}/src/c
# tangentsoft (not tangentsoft-fossil)
  cd ${HOME}/src/perl/hosts/tangentsoft
  inskin
  cd -  # should land me back in /h/v/src/c
}

function veryrarely() { # for stuff that hasn't updated in years
  cd fossil-scm
  fuel # really really rare chance to update
  cd -
  cd libfossil
  fsl
  c-pp
  pikmojicon
  cd -
  cd ${HOME}/src/php/hosts/james
  flint
  cd -
}

function tangentsoft-all() {
  # only one entry at the moment
  cd ${HOME}/src/perl/hosts/tangentsoft
  inskin
  cd - # should land me back in /h/v/src/c
  cd ${HOME}/src/c/hosts/tangentsoft/
  tangentsoft-fossil
  cd -
}

# Meant to be like all, but misses out sqlite docs, tips and other stuff
function common() {
  # First fossil
  fossil-all # this changes dir at end of fossil-all
  # then sqlite - can't use sqlite-all as it includes too much
  t="sqlite"
  cd ${t}
  ${t}-code
  sleep 5
  ${t}-forum
  sleep 5
  ${t}-althttpd
  sleep 5
  # now tcl/tk
  cd ../tcl
  tcl-code
  sleep 5
  cd ../tk
  tk-code
  cd .. # gets us back to ${MYHOME}
}

# Added because I do this a lot.  This will need expanding once we have more forums.
function forums() {
  cd fossil-scm # Presumes we're in ${FOSHOME}
  fossil-forum
  # now off to the second one
  cd ../sqlite
  sqlite-forum
  # and back home
  cd ..
}

function all() { # These each have a cd in them
# Note: does not include fsl
  fossil-all # code, forum, not book
  sleep 5
  sqlite-all # code, forum, althttpd, not tests
  sleep 5
  tcl-all    # code (tcl/tk), TCL Improvement Proposals (tip)
  sleep 5
  # tangentsoft-all has two paths, so we're not using it here
  cd ${HOME}/src/c/hosts/tangentsoft/
  tangentsoft-fossil # doesn't include inskinerator (under rarely)
  cd -
  sleep 5
  libfossil-all # added this as it doesn't make much sense to leave it out
  }

# Takes path arg, currently broken while I figure out how to feed an
# sqlite statement a variable's value.
#function getfossilpath() {
#    local input="${1}"
#    fossil sqlite ".mode list" ".headers off" "select name,datetime(mtime,'unixepoch','localtime') as date from config where name like '%ckout:%' and name like ;" -R <whatever-repo>
#}

pushd "${FOSHOME}" >/dev/null
# Let's add something to FOSCMD to make the operation specific
# the caseloop below processes in order. -u needs to be first if
# we want to sync unversioned artifacts
declare FOSCMDPARAMS
# Was here for getting everything and breadcrumbing where I was
# FOSCMDPARAMS=("-v" "--verily" "-R")
# Strip it back a bit, I think.
FOSCMDPARAMS=("-R")

FOSCMD="pull" # default value unless it gets changed by -u
if [ ${#*} -lt 1 ]; then # I want it all
  all # sleep is built in between stages
else #iterate, chuck it in if keyword isn't recognised.
  for t in ${*}; do
    case "${t}" in
    "-u"|"--unversioned")
      # sync can't push without user perms on remote, but can still pull unversioned artifacts
      FOSCMDPARAMS=("-u" "-v" "--verily" "-R")
      FOSCMD="sync"
#      dohelp
    ;;
#    "-p") # grab the next var from $2, if it's not blank
#        if [ ]; then
#          getfossilpath "$2"   # as yet uncoded
#          shift 2 # Now we have to pop that switch AND value
#        else
#          getfossilpath
#        fi
#    ;;
    "-s"|"--sync")
    # Sync needs remote perms - only works for projects supporting it
      FOSCMD="sync"
    ;;
    "help"|"-h"|"--help")
      dohelp # exits
    ;;
# this should really not be run on its own
    "--verbose")
      FOSCMDPARAMS=("--verbose" "-R")
    ;;
    "-v"|"version"|"--version") doversion  # exits
    ;;
# Each one of these handles path changing for itself
    "rarely"|"veryrarely"|"all"|"common")
      "${t}"
    ;;
    "fossil"|"sqlite"|"tcl"|"libfossil")
      "${t}"-all
    ;;
    "forum"|"forums")
      forums
    ;;
# All fossil-related stuff
    "fossil-forum"|"fossil-code"|"fossil-book"|"fuel")
      cd fossil-scm
      "${t}" # calls the function directly. I'll have to see if this works.
      cd ..
    ;;
    "book")
      cd fossil-scm
      fossil-book
      cd -
    ;;

# Some non-fossil stuff (hosted in a fossil)
    "fresh"|"Fresh")
      cd Fresh
      fresh
      cd ..
    ;;
# the host software for chisel (very rarely updated)
    "flint")
      cd ${HOME}/src/php/hosts/james
      flint
      cd -
    ;;
# and tangentsoft
    "inskin"|"Inskin"|"inskinerator"|"Inskinerator")
      cd ${HOME}/src/perl/hosts/tangentsoft
      inskin
      cd -
    ;;
    "tangentsoft-fossil")
      cd ${HOME}/src/c/hosts/tangentsoft
      tangentsoft-fossil
      cd -
    ;;
    "tangentsoft-all") 
      cd ${HOME}/src/c/hosts/tangentsoft
      tangentsoft-fossil
      cd -
    ;;
# My own fossilsource - I'll use chiselapp
    "fossilsource")
      cd ${HOME}/src/bash
      fossilsource-code
      cd -
    ;;
# All wanderinghorse stuff
    "libfossil-all")
      libfossil-all # should do libfossil-code and fnc but not libfossil-forum
    ;;
    "libfossil-code"|"cwal"|"cson"|"fsl"|"fnc"|"pikchr"|"pikmojicon"|"teaish"|"c-pp"|"whut"|"jaccwabyt"|"cssminc"|"whuuid"|"sewal"|"th1-sgb")
      cd libfossil
      ${t} # Seems a bit redundant to make this a full function call
      cd ..
    ;;
    "libwhut")  # same as whut above, but we have to call it slightly differently
    cd libfossil
    ${t##lib}
    cd ..  # Whoops, forgot this until now
    ;;
# All sqlite-related stuff
    "sqlite-code"|"sqlite-forum"|"sqlite-docsrc"|"sqlite-tests"|"sqlite-althttpd"|"sqlite-wasm"|"sqlite-sds")
      cd sqlite
      "${t}"
      cd -
    ;;
    "sqlite-lua")
      cd /h3/viking/src/c/sqlite
      "${t}"
      cd -
    ;;
    "docsrc") # this fills in the hole
      cd sqlite
      sqlite-"${t}"
      cd -
    ;;
    "althttpd"|"httpd") # whoops, is this duplicated with the above section?
      cd sqlite
      sqlite-althttpd
      cd ..
    ;;
    "docsrc")  # Why is this a duplicate?
      cd sqlite
      sqlite-docsrc
      cd ..
    ;;
    "sds") 
      cd sqlite
      sqlite-sds
      cd ..
    ;;
    "wasm")
      cd sqlite
      sqlite-wasm
      cd ..
    ;;
    "cloud"|"cloudsqlite"|"sqlite-cloud")
      cd sqlite
      sqlite-cloud
      cd ..
    ;;
# All tcl/tk-related stuff
    "tcl"|"tcl-all")
      tcl-all
    ;;
    "tcl-code"|"tcl-tips"|"wapp"|"tclconfig")
      cd tcl
      "${t}"
      cd -
    ;;
    "tk")
      cd "${t}"
      "${t}"-code  # Only the code at the moment.
      cd -
    ;;
    "tk-code")
      cd tk; pwd # TODO: why was this here?
      "${t}"
      cd -
    ;;
#    "jimtcl")
#    cd ${HOME}/src/tcl/hosts/msteveb/
#    "${t}"
#    cd -
#    ;;
    esac # end of case ${t}
  done
fi
popd >/dev/null
