| verzia 1.1, 2004/04/14 18:48:49 |
verzia 1.2, 2004/04/16 20:52:44 |
|
|
| # |
# |
| # cvs-switch.sh - easily switch between multiple CVS Repositories |
# cvs-switch.sh - easily switch between multiple CVS Repositories |
| # |
# |
| |
|
| |
# |
| |
# Usage: add next line to your ~/.bashrc, ~/.zshrc or etc.: |
| |
# |
| |
# alias cvs-switch='eval `$HOME/prog/cvs/scripts/shell/cvs-switch/cvs-switch.sh`' |
| |
# |
| |
# Then you can easily switch between CVS Repositories with alias 'cvs-switch' |
| |
# Available CVS Repositories are configured in your ~/.cvs-repositories.conf, |
| |
# see cvs-repositories.conf example |
| |
# |
| |
|
| |
# |
| # Developed by Lubomir Host 'rajo' <rajo AT platon.sk> |
# Developed by Lubomir Host 'rajo' <rajo AT platon.sk> |
| # Copyright (c) 2004 Platon SDG, http://platon.sk/ |
# Copyright (c) 2004 Platon SDG, http://platon.sk/ |
| # Licensed under terms of GNU General Public License. |
# Licensed under terms of GNU General Public License. |
|
|
| # 2004-04-13 - created |
# 2004-04-13 - created |
| # |
# |
| |
|
| # $Platon$ |
# $Platon: scripts/shell/cvs-switch/cvs-switch.sh,v 1.1 2004/04/14 18:48:49 rajo Exp $ |
| |
|
| # |
# |
| # This code is tested on Linux, FreeBSD and Solaris |
# This code is tested on Linux, FreeBSD and Solaris |
| # |
# |
| |
|
| |
print_message() |
| |
{ # {{{ |
| |
echo $*" " > /dev/stderr |
| |
} # }}} |
| |
|
| print_if_not_empty() |
print_if_not_empty() |
| { # {{{ |
{ # {{{ |
| name=$1 |
name=$1 |
| value=$2 |
value=$2 |
| if [ ! -z "$value" ]; then |
if [ ! -z "$value" ]; then |
| echo " $name = $value" |
print_message " $name = $value" |
| fi |
fi |
| } # }}} |
} # }}} |
| |
|
| Riadok 34 print_exported() |
|
| Riadok 51 print_exported() |
|
| echo "export $name=\"$value\"" |
echo "export $name=\"$value\"" |
| } # }}} |
} # }}} |
| |
|
| #cvs-switch() |
# |
| |
# This can't be function loaded by the shell, because error message appears: |
| |
# ... |
| |
# switch-cvs:50: bad substitution |
| |
# ... |
| |
|
| |
#switch-cvs() |
| #{ # {{{ |
#{ # {{{ |
| |
|
| CVS_SWITCH_CONFIG="$HOME/.cvs-repositories.conf" |
CVS_SWITCH_CONFIG="$HOME/.cvs-repositories.conf" |
| Riadok 61 print_exported() |
|
| Riadok 84 print_exported() |
|
| DOMAINNAME="`domainname`" |
DOMAINNAME="`domainname`" |
| ;; |
;; |
| *) |
*) |
| echo "Unsupported operating system, sorry..."; |
print_message "Unsupported operating system, sorry..."; |
| exit 1; |
exit 1; |
| ;; |
;; |
| esac |
esac |
| Riadok 83 print_exported() |
|
| Riadok 106 print_exported() |
|
| |
|
| i=1 |
i=1 |
| for rep in ${!REPOSITORIES}; do |
for rep in ${!REPOSITORIES}; do |
| eval rep_$i="$rep" |
eval rep_$i="$rep"; |
| eval "$SET_VARIABLES"; |
eval "$SET_VARIABLES"; |
| |
|
| echo "[33;1m$i - ${!title}[0;0m"; |
print_message |
| |
print_message "[33;1m$i - ${!title}[0;0m"; |
| print_if_not_empty "CVSROOT" "${!cvsroot}" |
print_if_not_empty "CVSROOT" "${!cvsroot}" |
| print_if_not_empty "CVS_RSH" "${!cvs_rsh}" |
print_if_not_empty "CVS_RSH" "${!cvs_rsh}" |
| |
|
| i=$((i + 1)) |
i=$((i + 1)) |
| done |
done |
| |
|
| echo -en "Your choice: [1] " |
print_message |
| |
print_message -en "Your choice: [1]:" |
| read x |
read x |
| if [ -z "$x" ]; then |
if [ -z "$x" ]; then |
| i=1; |
i=1; |