comparison setup @ 246:4eeccee282b1

Much more portable. Tested on Solaris (bourne shell yay).
author Edho Arief <edho@myconan.net>
date Mon, 07 Nov 2011 12:34:33 +0700
parents 719b0687d974
children c6ad8279b076
comparison
equal deleted inserted replaced
245:f74212d79fcb 246:4eeccee282b1
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() {
74 _init() { 74 _init() {
75 _script="${HOME}/${3}" 75 _script="${HOME}/${3}"
76 _scripttmp="${HOME}/.tmp.${3}" 76 _scripttmp="${HOME}/.tmp.${3}"
77 _data="${2}" 77 _data="${2}"
78 if [ -f "${_script}" ]; then 78 if [ -f "${_script}" ]; then
79 grep -v "${_data}" "${_script}" > "${_scripttmp}" 79 grep -v "`printf "%s\n" "${_data}" | sed 's/.*#//'`" "${_script}" > "${_scripttmp}"
80 mv -f "${_scripttmp}" "${_script}" 80 mv -f "${_scripttmp}" "${_script}"
81 fi 81 fi
82 case "${1}" in 82 case "${1}" in
83 install) 83 install)
84 _echo "${_data}" >> "${_script}" 84 _echo "${_data}" >> "${_script}"
109 ;; 109 ;;
110 *) 110 *)
111 _help 111 _help
112 ;; 112 ;;
113 esac 113 esac
114