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