.vimrc:
[nethome.git] / .bashrc
1 if [ -n "$_home_short_dotbashrc_norc" -o "${TERM#norc-}" != "$TERM" ];then
2         # We could get executed twice:
3         export _home_short_dotbashrc_norc=true
4         # Do not use $TZ as Solaris sshd(8) does not propagate it.
5         # Be aware you must use 'ssh -t' to propagate $TERM otherwise '=dumb'.
6         export TERM="${TERM#norc-}"
7         export _home_short_dotbashrc=true
8 fi
9
10 export PERL5LIB="$HOME/perl5/lib/perl5/`uname -m`-linux-thread-multi:$HOME/perl5/lib/perl5";
11
12 # "$PS1" for interactive shells detection.
13 if [ -n "$PS1" -a -z "$_home_short_dotbashrc" ];then
14         # We permit later reinitialization by unsetting it.
15         # During our execution we forbid spawning to prevent deadlock by:
16         #       source /etc/bashrc
17         #       . /etc/profile.d/lang.sh
18         #       unicode_start iso02.08
19         export _home_short_dotbashrc=true
20         # $TERM gets restored to its 'norc-' state after ~/.bashrc
21         # alias norc='TERM="norc-$TERM" ssh -t -o 'NoHostAuthenticationForLocalhost yes' $USER@localhost "cd $PWD; TERM=$TERM;"'
22         function norc { TERM="norc-$TERM" ssh -t -o 'NoHostAuthenticationForLocalhost yes' $USER@localhost "cd $PWD; TERM=$TERM;" "$@"; }
23
24 # Fix $USER and $LOGNAME (not $MAIL) for /etc/passwd line:
25 # root-lace:x:0:0:root for Jan Kratochvil:/home/root-lace:/bin/bash
26 if [ "$UID" -eq 0 -a "$USER" = "root" -a "$HOME" != "${HOME#*/root-}" ];then
27         USER="${HOME##*/}"
28         LOGNAME="$USER"
29 fi
30
31 if [ -f /etc/bashrc ];then source /etc/bashrc;fi
32
33 _bash_profile_addpath_fini=""
34 function _bash_profile_addpath  # <variablename>,<dirpathname>
35 {
36         local _varname _varval _varvalold _dirpathname _opt_f _opt_s
37         _opt_f=0;_opt_s=0
38         unset -v OPTIND
39         while getopts fs got;do
40                 case "$got" in
41                         [fs]) eval "_opt_$got=1" ;;
42                         *) return 1 ;;
43                         esac
44                 done
45         eval "_varname=\"\$$[$OPTIND+0]\""
46         eval "_dirpathname=\"\$$[$OPTIND+1]\""
47         if [ $_opt_f = 0 -a '!' -d "$_dirpathname" ];then return;fi
48         if [ $_opt_s = 1 -o -z "`eval "echo \\${$_varname}"`" ];then
49                 eval "$_varname='$_dirpathname'"
50         else
51                 # We want to prevent duplicates due to .bashrc reentrancy across fork(2)s. It is array!
52                 _bash_profile_addpath_fini="$_bash_profile_addpath_fini $_varname"
53                 # We want to override any original directories, place dirpathname first!
54                 eval "$_varname=\"$_dirpathname:\${$_varname}\""
55         fi
56         export "$_varname"
57 }
58 function _bash_profile_addpath_fini
59 {
60         local _varname
61         for _varname in `echo "$_bash_profile_addpath_fini"|tr ' ' '\n'|sort -u`;do
62                 eval "$_varname=\"`eval $(echo "echo \"\\$$_varname\"")|awk -v RS=':' '/[^\n]/{if (!x[$0]++) e=e":"$0;}END{print substr(e,2)}'`\""
63                 done
64         unset -v _bash_profile_addpath_fini
65 }
66
67 # Use reverse order of preferred directories:
68 # gid(1) dependency on: /opt/sfw/bin
69 # EUID="`id -u 2>/dev/null || /usr/xpg4/bin/id -u 2>/dev/null || gid -u`"
70 _bash_profile_addpath -f PATH            "/sbin"
71 _bash_profile_addpath -f PATH            "/usr/sbin"
72 _bash_profile_addpath -f PATH            "/bin"
73 _bash_profile_addpath -f PATH            "/usr/bin"
74 _bash_profile_addpath    PATH            "/usr/lib/ccache"
75 _bash_profile_addpath    PATH            "/usr/lib64/ccache"
76 [ $EUID -eq 0 ] && _bash_profile_addpath -f PATH "/usr/local/sbin"
77 _bash_profile_addpath -f PATH            "/usr/local/bin"
78 _bash_profile_addpath -f MANPATH         "/usr/X11R6/man"
79 _bash_profile_addpath -f MANPATH         "/usr/share/man"
80 _bash_profile_addpath -f MANPATH         "/usr/local/man"
81 _bash_profile_addpath -s JAVA_HOME       "/usr/java"
82 _bash_profile_addpath -s JAVA_HOME       "/usr/local/java"
83 uname_p="`uname -p 2>/dev/null || uname -m`"
84 for family in $HOME;do
85         for arch in $family $family/$uname_p;do
86                 # Do not "-f": We use /net !
87                 _bash_profile_addpath PATH            "$arch/bin"
88                 _bash_profile_addpath -s JAVA_HOME    "$arch/java"
89                 [ $EUID -eq 0 ] && _bash_profile_addpath PATH "$arch/sbin"
90                 _bash_profile_addpath LD_LIBRARY_PATH "$arch/lib64"
91                 _bash_profile_addpath LD_LIBRARY_PATH "$arch/lib"
92                 _bash_profile_addpath MANPATH         "$arch/man"
93                 done
94         done
95 _bash_profile_addpath -f -s CVSROOT ":pserver:pserver:@cvs.jankratochvil.net/cvs"       # default
96 [ -n "$JAVA_HOME" ] && _bash_profile_addpath PATH "$JAVA_HOME/bin"
97 _bash_profile_addpath    -s CVSROOT "$HOME/pserver/cvs"
98 _bash_profile_addpath    -s CVSROOT "$HOME/cvs"
99 _bash_profile_addpath    -s ANT_HOME "/usr/local/ant"
100
101 unset -f _bash_profile_addpath
102 _bash_profile_addpath_fini
103 unset -f _bash_profile_addpath_fini
104
105 # '2>/dev/null' to prevent: unalias: x: not found
106 # It must be run before `function's below as otherwise it would get embedded.
107 unalias 2>/dev/null cp  # -i
108 unalias 2>/dev/null mv  # -i
109 unalias 2>/dev/null rm  # -i
110 unalias 2>/dev/null df  # -h
111 unalias 2>/dev/null du  # -h
112 unalias 2>/dev/null ls  # --color=auto
113 unalias 2>/dev/null l.  # ls -d .* --color=auto
114 unalias 2>/dev/null ll  # ls -l --color=auto
115 unalias 2>/dev/null grep        # grep --color=auto
116
117 # Prevent processing of aliases during the parsing of this script file by
118 # `eval':
119 eval '
120         function grep {(unset grep; ( ulimitme; grep "$@"; ); );}
121         function ls {(unset ls; ( ls -bF "$@"; ); );}
122         function l { ls -lbF "$@"; }
123         if which vim &>/dev/null;then
124                 alias vi="vim"
125         else
126                 echo >&2 "WARNING: No vim(1)."
127         fi
128         function grepb { grep --binary-files=binary "$@"; }
129         function L { lynx "$@"; }
130         function chown {(unset chown; ( chown --no-dereference "$@"; ); );}
131         function chgrp {(unset chgrp; ( chgrp --no-dereference "$@"; ); );}
132         function hexedit {(unset hexedit; ( hexedit -s "$@"; ); );}
133         function cvs2cl {(unset cvs2cl; ( cvs2cl --window 3600 --separate-header --no-wrap "$@"; ); );}
134         function cvsfiles { cvsutil --files --print "$@"; }
135         function cvsignores { cvsutil --ignores --print "$@"; }
136         function cvsignoresall { cvsutil --ignores --workings --print "$@"; }
137         function cvsignoresrm { cvsutil --ignores --rm "$@"; }
138         function cvsignoresrmall { cvsutil --ignores --workings --rm "$@"; }
139         function cvsignoresallrm { cvsutil --ignores --workings --rm "$@"; }
140         function svnignoresall { svn status |sed -n "s/^[?]      //p" "$@"; }
141         function svnignoresallrm { svn status |sed -n "s/^[?]      //p"|tr "\n" "\0"|xargs -0 rm -rf "$@"; }
142         function ignores { find -name "*.orig" -o -name ".#*" -o -name "*~" "$@"; }
143         function ignoresrm { ignores "$@" | xargs rm -f; }
144         function ignoresall { ignores -o -name "*.rej" "$@"; }
145         function ignoresallrm { ignoresall "$@" | xargs rm -f; }
146         function disass { objdump -D --target=binary --architecture=i386:x86-64 "$@"; }
147         function disass32 { objdump -D --target=binary --architecture=i386 "$@"; }
148         function cal {(unset cal; ( cal -m "$@"; ); );}
149         function vncreadonly { vncviewer -FullColor -Shared -ViewOnly "$@"; }
150         function diff {(unset diff; ( diff -dup "$@"; ); );}
151         $(: MAKEFLAGS= - "make install" does not expect -j and .spec files do not force -j1.)
152         function rpmbuildlocal { MAKEFLAGS= n rpmbuild --define "_topdir $PWD" --define "_builddir $PWD" --define "_rpmdir $PWD" --define "_sourcedir $PWD" --define "_specdir $PWD" --define "_srcrpmdir $PWD" --define "_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" "$@"; rmdir &>/dev/null BUILDROOT; }
153         function gdbn { gdb -nx --command=~/.gdbinit "$@"; }
154         function hd { od -Ax -tx1; }
155         function wget {(unset wget; ( wget --no-check-certificate "$@"; ); );}
156         function ucwkbd { setxkbmap -layout us,cz -variant ,ucw -option grp:caps_switch; }
157 '
158
159 unset command_not_found_handle
160 shopt -u progcomp # Disable 'bash-completion' rpm
161 export IGNOREEOF=10
162 # '2>/dev/null' to prevent: TMOUT: readonly variable
163 [ -n "$SSH_TTY" ] && export TMOUT=900 2>/dev/null
164 export EDITOR='vim'
165 [ -x /bin/less ] && export PAGER='/bin/less -rMMh5cis'
166
167 export PERL_LOCAL_LIB_ROOT="$HOME/perl5";
168 export PERL_MB_OPT="--install_base $HOME/perl5";
169 export PERL_MM_OPT="INSTALL_BASE=$HOME/perl5";
170 # Sometimes needed in non-interactive .bashrc.
171 # Unconditionally it would break quilt.
172 export PATH="$HOME/perl5/bin:$PATH";
173
174 for file in $HOME/.bookmarks.html;do
175         export WWW_HOME="file://$HOME/"
176         [ -r $file ] && export WWW_HOME="file://$file"
177         done
178 export GREP_OPTIONS="--binary-files=without-match --directories=skip"
179 if echo x|GREP_OPTIONS="--exclude=y" grep -q x 2>/dev/null;then
180         export GREP_OPTIONS="$GREP_OPTIONS --exclude=tags --exclude=TAGS --exclude=ChangeLog* --exclude=*.svn-base --exclude=*~"
181         # FIXME: grep(1) ignores subdirectories for --exclude.
182         #export GREP_OPTIONS="$GREP_OPTIONS --exclude=testsuite --exclude=.pc --exclude=.svn --exclude=CVS --exclude=po"
183 fi
184 if [ -n "$PS1" ];then   # set only in interactive sessions
185         if [ ! -f /MOCK ];then
186                 export PS1='[bash]${LOGNAME}@${HOSTNAME}:${PWD}# '
187         else
188                 export PS1='[bash]${LOGNAME}@MOCK-'"`cat /MOCK`"':${PWD}# '
189         fi
190         export PS1='\[\017\]'"$PS1"     # \017=std charmap
191         export PS1='\[\033%G\]'"$PS1"   # \033%G=utf-8
192         # Do not: kbd_mode -u # utf-8
193         # as it breaks keyboard state in X and it is not permitted for non-root.
194 fi
195 export MINICOM="-m -c on"       # metakeys+color
196 export HISTSIZE=100000
197 export HISTFILESIZE="$HISTSIZE"
198 export GDBHISTFILE="$HOME/.gdb_history"
199 export CVS_RSH="ssh"
200 export TZ=":/usr/share/zoneinfo/Europe/Prague"
201 #export TZ=":/usr/share/zoneinfo/Canada/Eastern"
202 export PYTHONUNBUFFERED=1
203 export MAKEFLAGS=
204 cpus="`getconf _NPROCESSORS_ONLN`"
205 if [ -n "$cpus" ];then
206         MAKEFLAGS="$MAKEFLAGS -j$[$cpus*3/2]"
207 fi
208 unset cpus
209 # Do not: grep -w "$TERM" /etc/termcap >/dev/null || export TERM=vt220
210 # as Sun workaround as Debian misses: /etc/termcap
211 # expects: $uname_p
212 [ "$TERM" = vt220 -a "${uname_p%86}" != "$uname_p" ] && export TERM=linux
213 if grep 2>/dev/null -q '^..............:0C38 00000000:0000 0A ' /proc/net/tcp \
214 || grep 2>/dev/null -q '^....: 00000000000000000000000000000000:0C38 00000000000000000000000000000000:0000 0A ' /proc/net/tcp6 \
215 ;then
216         export  http_proxy=http://127.0.0.1:3128/
217         export https_proxy=http://127.0.0.1:3128/
218         export   ftp_proxy=http://127.0.0.1:3128/
219 fi
220 _selfabs=
221 [ "$_selfabs" = "${_selfabs#/}" ] && _selfabs="$BASH_SOURCE"
222 [ "$_selfabs" = "${_selfabs#/}" ] && _selfabs="$PWD/.bashrc"
223 [ -r "$_selfabs" ] || unset _selfabs
224 [ -n "$_selfabs" ] && export VIMINIT="source `echo "$_selfabs"|sed 's/[.]bashrc$/.vimrc/'`"
225
226 # Force English.
227 unset LANG LANGUAGE `set|sed -n 's/^\(LC_[^=]*\)=.*$/\1/p'`
228 export LANG=en_US.UTF-8
229 # Force strcoll() to sort case-sensitively! (empty/undef doesn't work)
230 export LC_COLLATE=C
231 # Do not: # Prevent: perl: warning: Setting locale failed.
232 #         # due to LC_COLLATE=C and LC_ALL=(unset)
233 #         export LC_ALL=C
234 # as it breaks Mutt "utf-8" and somehow it is no longer needed.
235 # Re: [Bug-readline] Readline 6.0 patch 004 trapped signal echoed to conso
236 # http://lists.gnu.org/archive/html/bug-readline/2009-09/msg00006.html
237 # 2>/dev/null for possible: stty: standard input: Inappropriate ioctl for device
238 stty -echoctl 2>/dev/null
239
240 function wclines { awk '{x[$0]++}END{for (i in x) print x[i]"\t"i}'; }
241 # SunOS does not support "-m"
242 export ULIMITME_OPTS=""
243 for i in "-m 100000" "-d 150000" "-v 200000";do
244         (ulimit $i 2>/dev/null) && ULIMITME_OPTS="$ULIMITME_OPTS $i"
245         done
246 # Prevent: ulimit:  -m 100000 -d 150000 -v 200000: invalid number
247 # by forcing our known $IFS value; eval(1) is needed to take $IFS to effect:
248 function ulimitme { IFS=" " eval "ulimit $ULIMITME_OPTS"; }
249 function finame { find . -false `
250         awk </dev/null 'BEGIN{ for (i=1;i<ARGC;i++) print " -o -iname *"ARGV[i]"*"; }' "$@"
251         `; }
252 function mkcd { mkdir -p "$1"; cd "$1"; }
253 function pushdmk { mkdir -p "$1"; pushd "$1"; }
254 function rsync {(unset rsync; n rsync -a -v -e ssh --progress --stats --inplace --rsync-path='nice -n20 ionice -c3 rsync' "$@"; );}
255 function tohex { od -An -txC|tr -d '\n '|tr 'a-f' 'A-F';echo; }
256 function edall {
257         find -type f|while read -r i;do
258                 (awk </dev/null 'BEGIN{ for (i=1;i<ARGC;i++) print ARGV[i]; }' "$@";echo -e 'w\nq')|ed -s "$i"
259                 done
260         }
261 function mi { (
262         set -ex;cd "$1";while true;do test "$PWD" != "/";if [ -e configure.in -o -e Makefile.PL ];then break;fi;cd ..;done;make install
263         ); }
264 function ctags {(unset ctags
265         if [ $# -ne 0 -a '(' $# -ne 1 -o "$1" '!=' "--c-types=+px" ')' ];then ctags "$@";else
266                 find -name testsuite -prune -o -name gdbserver -prune -o -name .pc -prune -o -name .svn -prune -o \
267                                 -type f -a '!' -name tags -a '!' -name TAGS -a '(' -false \
268                                                 -o -name "*.[chCy]" \
269                                                 -o -name "*.cc"    \
270                                                 -o -name "*.cxx"   \
271                                                 -o -name "*.cpp"   \
272                                                 -o -name "*.[Ss]"  \
273                                                 -o -name "*.java"  \
274                                                 -o -name "*.p[lm]" \
275                                                 -o -name "*.py" \
276                                                 -o -name "*.exp" \
277                                                 ')' \
278                                 |ctags --file-tags -L - --langmap=Tcl:+.exp "$@"
279         fi; );}
280 function ctagsh { ctags "--c-types=+px"; }
281 function cpan {(unset cpan; if [ $# = 0 ];then cpan;else perl -MCPAN -e "install qw($*);";fi; );}
282 function exx { cd "`unset exx;exx "$@"|tee /proc/self/fd/2|tail -n1|sed -n 's/^extdir=//p'`"; }
283 function debuginfo { if test -n "$*";then echo "$*";else cat;fi \
284         |xargs rpm -qf|xargs rpmquery --qf '%{SOURCERPM}\n'|sed 's/-[^-]*-[^-]*[.]src[.]rpm$/-debuginfo/'|sort -u; }
285 function ipcsrmall { ipcs|awk '/- Shared Memory/{x="-m"}/- Semaphore/{x="-s"}/^0x/{print "ipcrm "x" "$2}'; }
286 function eog {(unset eog; touch /tmp/eog.$$;eog "$@" {,,,,,,,,,}/tmp/eog.$$;rm -f /tmp/eog.$$; );}
287 function diffc { diff -dup "$@"|grep -v '^\(Only in \|Binary files\)'; }
288 function diffi { diffc -X ~/.diffi.list "$@" | diffdecvs; }
289 function cvs {(unset cvs
290         local _opts _opts_d _now _line _o
291         _opts_d="-d"
292         if grep -iw '\(sources.redhat.com\|sourceware.org\):/cvs/src' CVS/Root &>/dev/null;then _opts_d="";fi
293         if grep -iw '\(cvs.fedoraproject.org\):/cvs/pkgs' CVS/Root &>/dev/null;then _opts_d="";fi
294         if grep '^tests/kernel/syscalls/ptrace' CVS/Repository &>/dev/null;then _opts_d="";fi
295         _now=false
296         _line=""
297         _opts=""
298         while [ $# != 0 ];do
299                 _o="$1"
300                 shift
301                 _line="$_line $_o"
302                 if [ "$_o" = "--" ] && ! $_now;then _now=true;continue;fi
303                 if [ "${_o#-}" != "$_o" ] && ! $_now;then continue;fi
304                 if [ "$_o" = update -o "$_o" = upd -o "$_o" = up ];then _opts="$_opts_d";fi
305                 break
306                 done
307         cvs $_line $_opts "$@"
308         ); }
309 function perlrpm { repoquery -q --whatprovides $(for i in "$@";do echo "perl($i)";done|sed -e 's/\//::/g' -e 's/[.]pm//g'); }
310 # `-u' limits the search to $UID.
311 function pidof
312 {(unset pidof
313   if [ "$1" = "-u" ];then
314     shift
315     local r="$(pidof "$@")"
316     local space=""
317     local p
318     for p in $r;do
319       if grep -q "$(echo -e "^Uid:\t$UID\t")" "/proc/$p/status";then
320         echo -n "${space}$p"
321         space=" "
322       fi
323     done
324     echo
325   else
326     pidof "$@"
327   fi
328 )}
329 function sumlog { find "$@" ! -name config.log -name "*.log" -o -name "*.sum"; }
330 function sourcewarecvscheckout {(set -ex
331         ! test -d src
332         ! test -d $1-cvs 
333         (set +x;cvs -z3 -d :pserver:anoncvs:@sourceware.org:/cvs/src checkout $1)
334         mv src $1-cvs
335         cd $1-cvs
336         (set +x;cvs update)
337         #(set +x;cvsignoresall)
338         (set +x;ignoresall)
339         );}
340 function gdbgitclone { git clone git://sourceware.org/git/gdb.git gdb-git; }
341 function binutilsgitclone { git clone git://sourceware.org/git/binutils.git binutils-git; }
342 function archergitclone { git clone git://sourceware.org/git/archer.git archer-git; }
343 function gdbcvscheckout { sourcewarecvscheckout gdb; }
344 function binutilscvscheckout { sourcewarecvscheckout binutils; }
345 function uri_escape   { perl -MURI::Escape -le '$_=<>;chomp;print uri_escape   $_;'; };
346 function uri_unescape { perl -MURI::Escape -le '$_=<>;chomp;print uri_unescape $_;'; };
347 alias fetchmail='n fetchmail'
348 function rpmsrclist
349 {
350         if [ -z "$*" ]; then
351                 echo >&2 "rpmsrclist gcc-4.3.2-7 [4.4.0-0.25 [-|http://kojipkgs.fedoraproject.org/packages/gcc/4.4.0/0.25/]]"
352         else
353                 rpm -q --qf '%{SOURCERPM} %{name}-%{version}-%{release}.%{arch}\n' -a \
354                         | grep "^$1.src.rpm " | sed 's/^[^ ]* //' \
355                         | \
356                                 if [ -z "$2" ]; then \
357                                         cat; \
358                                 else \
359                                         sed "s/-$(echo "$1"|sed 's/^.*-\([^-]*-[^-]*\)$/\1/')/-$2/"
360                                 fi \
361                         | \
362                                 if [ -z "$3" ]; then \
363                                         cat; \
364                                 else \
365                                         if [ "$3" != - ]; then
366                                                 sed "s#.*#$3&.rpm#"; \
367                                         else \
368                                                 base="$(echo "$1"|sed 's/^\(.*\)-[^-]*-[^-]*$/\1/')"; \
369                                                 sed "s#^.*-\([^-]*\)-\([^-]*\)\.\([^.]*\)\$#http://kojipkgs.fedoraproject.org/packages/$base/\1/\2/\3/&.rpm#"; \
370                                         fi; \
371                                 fi \
372                         | sort -u
373         fi
374 }
375 function valgrind {(set -e;unset valgrind;s=~/.python.valgrind;rm -f $s;cp -p /usr/share/doc/python-devel-2.*/valgrind-python.supp $s;patch $s <$s.patch;perl -i -e 'undef $/;$_=<>;1 while s/^(?:###)?({\n)(?:###)?( *ADDRESS_IN_RANGE.*\n(?:[^}#].*\n)*)###/$1$2/gm;print;' $s;valgrind --num-callers=50 --suppressions=$s "$@";);}
376 function yumupdate {(ulimit -v unlimited;yum makecache;yum -y --skip-broken update "$@";);}
377 function gitcommit { git commit -a -m .; }
378 function gpg {(unset gpg; http_proxy= all_proxy= HTTP_PROXY= ALL_PROXY= gpg "$@"; );}
379
380 ulimit -S -c 0
381 set +H
382 shopt -s mailwarn
383 shopt -s direxpand
384 unset OPTIND
385 umask 022
386
387 if [ -f "$HOME/.bashrc.local" ];then source "$HOME/.bashrc.local";fi
388
389 # Interactive part:
390 for key in $HOME/.ssh/id_dsa;do
391
392         # DISABLED now.
393         continue
394
395         [ -r "$key" ] || continue
396         # Do not: [ -n "$SSH_TTY" ] && continue
397         # as we may want foreign SSH keys too.
398
399         agenteval=/tmp/.$USER.ssh-agent.eval
400         if lockfile -1 -r 3 -l 10 -s 1 $agenteval.lock;then
401                 test -f $agenteval -a -O $agenteval -a -G $agenteval &&
402                                 # ">/dev/null" to prevent: echo Agent pid 31074
403                                 source $agenteval >/dev/null
404                 if [ "ssh-agent" != "`(xargs -0 </proc/"$SSH_AGENT_PID"/cmdline sh -c 'echo "$0"') 2>/dev/null `" ];then
405                         rm -f $agenteval
406                         (test ! -e $agenteval && ssh-agent -s >$agenteval) || echo >&2 'Failing ssh-agent!'
407                         # ">/dev/null" to prevent: echo Agent pid 31074
408                         source $agenteval >/dev/null
409                 fi
410                 rm -f $agenteval.lock
411         fi
412
413         # Prevent gdm(8) lockups on non-interactive consoles.
414         tty -s || continue
415         (ssh-add -l|grep -qw "$key") && continue
416         if lockfile -! -1 -r 0 $agenteval.input.lock 2>/dev/null;then
417                 echo >&2 -n "Locking: $agenteval.input.lock ... "
418                 lockfile -1 -r -1 $agenteval.input.lock
419                 echo >&2 "locked"
420         fi
421         # Recheck identity existence after the lock acquire
422         if ssh-add -l|grep -qw "$key";then
423                 echo >&2 "Identity $key already appended in the meantime."
424         else
425                 # "2>/dev/null" to prevent: Identity added: .ssh/id_dsa (.ssh/id_dsa)
426                 ssh-add "$key" 2>/dev/null
427         fi
428         rm -f $agenteval.input.lock
429         echo >&2 "$agenteval.input.lock unlocked."
430 done
431 unset agenteval
432
433         unset _home_short_dotbashrc     # permit later reinitializations
434 fi      # _home_short_dotbashrc
435
436 true    # Prevent crash in '-e' mode