changeset 325:795ad57794a6

[setup] Returning solaris compatibility.
author Edho Arief <edho@myconan.net>
date Sun, 18 Mar 2012 16:02:08 +0700
parents 391f2b64900e
children b27e43878127
files setup
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/setup	Sun Mar 18 13:23:06 2012 +0700
+++ b/setup	Sun Mar 18 16:02:08 2012 +0700
@@ -1,5 +1,8 @@
 #!/bin/sh
 
+set -u
+set -e
+
 basedir="`dirname "${0}"`"
 cd "${basedir}"
 basedir="`pwd`"
@@ -50,7 +53,7 @@
   fi
   _srcfile="${rcdir}/${2}"
   _dstfile="${HOME}/${3}"
-  _dstdir="${_dstfile%/*}"
+  _dstdir="`_echo "${_dstfile}" | sed -e 's,^\(.*\)/[^/]*$,\1,'`"
   mkdir -p "${_dstdir}"
   if test ! -h "${_dstfile}"; then
     if test -f "${_dstfile}"; then
@@ -76,9 +79,10 @@
 _init() {
   _script="${HOME}/${3}"
   _scripttmp="${HOME}/.tmp.${3}"
+  rm -f "${_scripttmp}"
   _data="${2}"
   if [ -f "${_script}" ]; then
-    grep -v "`printf "%s\n" "${_data}" | sed 's/.*#//'`" "${_script}" > "${_scripttmp}"
+    sed -e "/`_echo "${_data}" | sed -e 's/.*#//'`/d" "${_script}" > "${_scripttmp}"
     mv -f "${_scripttmp}" "${_script}"
   fi
   case "${1}" in
@@ -100,9 +104,9 @@
 
 case "${1}" in
   install|uninstall)
-    for i in tcsh bash zsh; do
-      _"${i}" "${1}"
-    done
+    _tcsh "${1}"
+    _bash "${1}"
+    _zsh "${1}"
     _rc "${1}" "tmux" ".tmux.conf"
     _rc "${1}" "hg" ".hgrc"
     _rc "${1}" "vimrc" ".vimrc"