# HG changeset patch # User Edho Arief # Date 1351252633 -25200 # Node ID c171c29e13f5b436e2d4a94f1824c94d63a9fadd # Parent d0f9e435d36d76baca95b091d707c3276a5ecd6e A bit of documentation. diff -r d0f9e435d36d -r c171c29e13f5 setup --- a/setup Mon Oct 08 15:29:49 2012 +0700 +++ b/setup Fri Oct 26 18:57:13 2012 +0700 @@ -1,19 +1,38 @@ #!/bin/sh +# This script is bourne-shell compatible. +# Or at least it is when I last tested it in Solaris 10. + +# Ensure no variable is empty when used. set -u +# Stop on any error. set -e +# Get directory where this script and dotfiles are located. +# $0 contains either full path when executed from a PATH (godwhy) +# or with complete path or ./ when executed that way. +# Therefore it's safe to use dirname in this case. basedir="`dirname "${0}"`" + +# To get actual path, go to the directory and pwd from it. cd "${basedir}" basedir="`pwd`" + +# FIXME: test existence of the directories. +# dotfiles rcdir="${basedir}/rc" +# misc scripts bindir="${basedir}/bin" +# Make sure $HOME points somewhere. +# FIXME: ensure it is writable (or maybe not). test -n "${HOME}" || exit 1 +# A safe echo. _echo() { _echon "${*}"; printf "\n" } +# A safe and cross platform echo -n. _echon() { printf '%s' "${*}" }