Mercurial > ec-dotfiles
comparison setup @ 404:c171c29e13f5
A bit of documentation.
| author | Edho Arief <edho@myconan.net> | 
|---|---|
| date | Fri, 26 Oct 2012 18:57:13 +0700 | 
| parents | 0aabb2b34ef6 | 
| children | fd0a889066a6 | 
   comparison
  equal
  deleted
  inserted
  replaced
| 403:d0f9e435d36d | 404:c171c29e13f5 | 
|---|---|
| 1 #!/bin/sh | 1 #!/bin/sh | 
| 2 | 2 | 
| 3 # This script is bourne-shell compatible. | |
| 4 # Or at least it is when I last tested it in Solaris 10. | |
| 5 | |
| 6 # Ensure no variable is empty when used. | |
| 3 set -u | 7 set -u | 
| 8 # Stop on any error. | |
| 4 set -e | 9 set -e | 
| 5 | 10 | 
| 11 # Get directory where this script and dotfiles are located. | |
| 12 # $0 contains either full path when executed from a PATH (godwhy) | |
| 13 # or with complete path or ./<scriptname> when executed that way. | |
| 14 # Therefore it's safe to use dirname in this case. | |
| 6 basedir="`dirname "${0}"`" | 15 basedir="`dirname "${0}"`" | 
| 16 | |
| 17 # To get actual path, go to the directory and pwd from it. | |
| 7 cd "${basedir}" | 18 cd "${basedir}" | 
| 8 basedir="`pwd`" | 19 basedir="`pwd`" | 
| 20 | |
| 21 # FIXME: test existence of the directories. | |
| 22 # dotfiles | |
| 9 rcdir="${basedir}/rc" | 23 rcdir="${basedir}/rc" | 
| 24 # misc scripts | |
| 10 bindir="${basedir}/bin" | 25 bindir="${basedir}/bin" | 
| 11 | 26 | 
| 27 # Make sure $HOME points somewhere. | |
| 28 # FIXME: ensure it is writable (or maybe not). | |
| 12 test -n "${HOME}" || exit 1 | 29 test -n "${HOME}" || exit 1 | 
| 13 | 30 | 
| 31 # A safe echo. | |
| 14 _echo() { | 32 _echo() { | 
| 15 _echon "${*}"; printf "\n" | 33 _echon "${*}"; printf "\n" | 
| 16 } | 34 } | 
| 35 # A safe and cross platform echo -n. | |
| 17 _echon() { | 36 _echon() { | 
| 18 printf '%s' "${*}" | 37 printf '%s' "${*}" | 
| 19 } | 38 } | 
| 20 | 39 | 
| 21 _tcsh() { | 40 _tcsh() { | 
