comparison setup @ 248:fbb03c862b63

Awesome merge.
author Edho Arief <edho@myconan.net>
date Tue, 08 Nov 2011 11:59:49 +0700
parents 4eeccee282b1
children c6ad8279b076
comparison
equal deleted inserted replaced
132:53b39ca5a6ea 248:fbb03c862b63
17 17
18 _tcsh() { 18 _tcsh() {
19 case "$1" in 19 case "$1" in
20 uninstall|install) 20 uninstall|install)
21 _rc "${1}" "tcsh" ".ecos_tcsh" 21 _rc "${1}" "tcsh" ".ecos_tcsh"
22 _init "${1}" '[ -r "${HOME}/.ecos_tcsh" ] && source "${HOME}/.ecos_tcsh" #ECCORE_TCSH' ".cshrc" 22 _init "${1}" 'test -r "${HOME}/.ecos_tcsh" && source "${HOME}/.ecos_tcsh" #ECCORE_TCSH' ".cshrc"
23 ;; 23 ;;
24 esac 24 esac
25 } 25 }
26 26
27 _bash() { 27 _bash() {
42 ;; 42 ;;
43 esac 43 esac
44 } 44 }
45 45
46 _rc() { 46 _rc() {
47 if test -z "${3}" || test -z "${2}" || test -z "${1}"; then
48 _echo "Invalid command."
49 return
50 fi
47 _srcfile="${rcdir}/${2}" 51 _srcfile="${rcdir}/${2}"
48 _dstfile="${HOME}/${3}" 52 _dstfile="${HOME}/${3}"
49 if test ! -h "${_dstfile}"; then 53 if test ! -h "${_dstfile}"; then
50 if test -f "${_dstfile}"; then 54 if test -f "${_dstfile}"; then
51 cp "${_dstfile}" "${_dstfile}.bak" 55 cp "${_dstfile}" "${_dstfile}.bak"
56 _echo "${_dstfile} backed up to ${_dstfile}.bak"
52 elif test -d "${_dstfile}"; then 57 elif test -d "${_dstfile}"; then
53 cp -r "${_dstfile}" "${_dstfile}.bak" 58 cp -r "${_dstfile}" "${_dstfile}.bak"
59 _echo "Directory ${_dstfile} backed up to ${_dstfile}.bak"
54 fi 60 fi
55 _echo "${_dstfile} backed up to ${_dstfile}.bak"
56 fi 61 fi
57 rm -f "${_dstfile}" 62 rm -rf "${_dstfile}"
58 case "${1}" in 63 case "${1}" in
59 install) 64 install)
60 ln -fs "${_srcfile}" "${_dstfile}" 65 ln -fs "${_srcfile}" "${_dstfile}"
61 _echo "Installed ${_dstfile}" 66 _echo "Installed ${_dstfile}"
62 ;; 67 ;;
69 _init() { 74 _init() {
70 _script="${HOME}/${3}" 75 _script="${HOME}/${3}"
71 _scripttmp="${HOME}/.tmp.${3}" 76 _scripttmp="${HOME}/.tmp.${3}"
72 _data="${2}" 77 _data="${2}"
73 if [ -f "${_script}" ]; then 78 if [ -f "${_script}" ]; then
74 grep -v "${_data}" "${_script}" > "${_scripttmp}" 79 grep -v "`printf "%s\n" "${_data}" | sed 's/.*#//'`" "${_script}" > "${_scripttmp}"
75 mv -f "${_scripttmp}" "${_script}" 80 mv -f "${_scripttmp}" "${_script}"
76 fi 81 fi
77 case "${1}" in 82 case "${1}" in
78 install) 83 install)
79 _echo "${_data}" >> "${_script}" 84 _echo "${_data}" >> "${_script}"
104 ;; 109 ;;
105 *) 110 *)
106 _help 111 _help
107 ;; 112 ;;
108 esac 113 esac
114