+unset command_not_found_handle
[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 export IGNOREEOF=10
161 # '2>/dev/null' to prevent: TMOUT: readonly variable
162 [ -n "$SSH_TTY" ] && export TMOUT=900 2>/dev/null
163 export EDITOR='vim'
164 [ -x /bin/less ] && export PAGER='/bin/less -rMMh5cis'
165
166 export PERL_LOCAL_LIB_ROOT="$HOME/perl5";
167 export PERL_MB_OPT="--install_base $HOME/perl5";
168 export PERL_MM_OPT="INSTALL_BASE=$HOME/perl5";
169 # Sometimes needed in non-interactive .bashrc.
170 # Unconditionally it would break quilt.
171 export PATH="$HOME/perl5/bin:$PATH";
172
173 for file in $HOME/.bookmarks.html;do
174         export WWW_HOME="file://$HOME/"
175         [ -r $file ] && export WWW_HOME="file://$file"
176         done
177 export GREP_OPTIONS="--binary-files=without-match --directories=skip"
178 if echo x|GREP_OPTIONS="--exclude=y" grep -q x 2>/dev/null;then
179         export GREP_OPTIONS="$GREP_OPTIONS --exclude=tags --exclude=TAGS --exclude=ChangeLog* --exclude=*.svn-base --exclude=*~"
180         # FIXME: grep(1) ignores subdirectories for --exclude.
181         #export GREP_OPTIONS="$GREP_OPTIONS --exclude=testsuite --exclude=.pc --exclude=.svn --exclude=CVS --exclude=po"
182 fi
183 if [ -n "$PS1" ];then   # set only in interactive sessions
184         if [ ! -f /MOCK ];then
185                 export PS1='[bash]${LOGNAME}@${HOSTNAME}:${PWD}# '
186         else
187                 export PS1='[bash]${LOGNAME}@MOCK-'"`cat /MOCK`"':${PWD}# '
188         fi
189         export PS1='\[\017\]'"$PS1"     # \017=std charmap
190         export PS1='\[\033%G\]'"$PS1"   # \033%G=utf-8
191         # Do not: kbd_mode -u # utf-8
192         # as it breaks keyboard state in X and it is not permitted for non-root.
193 fi
194 export MINICOM="-m -c on"       # metakeys+color
195 export HISTSIZE=100000
196 export HISTFILESIZE="$HISTSIZE"
197 export GDBHISTFILE="$HOME/.gdb_history"
198 export CVS_RSH="ssh"
199 export TZ=":/usr/share/zoneinfo/Europe/Prague"
200 #export TZ=":/usr/share/zoneinfo/Canada/Eastern"
201 export PYTHONUNBUFFERED=1
202 export MAKEFLAGS=
203 cpus="`getconf _NPROCESSORS_ONLN`"
204 if [ -n "$cpus" ];then
205         MAKEFLAGS="$MAKEFLAGS -j$[$cpus*3/2]"
206 fi
207 unset cpus
208 # Do not: grep -w "$TERM" /etc/termcap >/dev/null || export TERM=vt220
209 # as Sun workaround as Debian misses: /etc/termcap
210 # expects: $uname_p
211 [ "$TERM" = vt220 -a "${uname_p%86}" != "$uname_p" ] && export TERM=linux
212 if grep 2>/dev/null -q '^..............:0C38 00000000:0000 0A ' /proc/net/tcp \
213 || grep 2>/dev/null -q '^....: 00000000000000000000000000000000:0C38 00000000000000000000000000000000:0000 0A ' /proc/net/tcp6 \
214 ;then
215         export  http_proxy=http://127.0.0.1:3128/
216         export https_proxy=http://127.0.0.1:3128/
217         export   ftp_proxy=http://127.0.0.1:3128/
218 fi
219 _selfabs=
220 [ "$_selfabs" = "${_selfabs#/}" ] && _selfabs="$BASH_SOURCE"
221 [ "$_selfabs" = "${_selfabs#/}" ] && _selfabs="$PWD/.bashrc"
222 [ -r "$_selfabs" ] || unset _selfabs
223 [ -n "$_selfabs" ] && export VIMINIT="source `echo "$_selfabs"|sed 's/[.]bashrc$/.vimrc/'`"
224
225 # Force English.
226 unset LANG LANGUAGE `set|sed -n 's/^\(LC_[^=]*\)=.*$/\1/p'`
227 export LANG=en_US.UTF-8
228 # Force strcoll() to sort case-sensitively! (empty/undef doesn't work)
229 export LC_COLLATE=C
230 # Do not: # Prevent: perl: warning: Setting locale failed.
231 #         # due to LC_COLLATE=C and LC_ALL=(unset)
232 #         export LC_ALL=C
233 # as it breaks Mutt "utf-8" and somehow it is no longer needed.
234 # Re: [Bug-readline] Readline 6.0 patch 004 trapped signal echoed to conso
235 # http://lists.gnu.org/archive/html/bug-readline/2009-09/msg00006.html
236 # 2>/dev/null for possible: stty: standard input: Inappropriate ioctl for device
237 stty -echoctl 2>/dev/null
238
239 function wclines { awk '{x[$0]++}END{for (i in x) print x[i]"\t"i}'; }
240 # SunOS does not support "-m"
241 export ULIMITME_OPTS=""
242 for i in "-m 100000" "-d 150000" "-v 200000";do
243         (ulimit $i 2>/dev/null) && ULIMITME_OPTS="$ULIMITME_OPTS $i"
244         done
245 # Prevent: ulimit:  -m 100000 -d 150000 -v 200000: invalid number
246 # by forcing our known $IFS value; eval(1) is needed to take $IFS to effect:
247 function ulimitme { IFS=" " eval "ulimit $ULIMITME_OPTS"; }
248 function finame { find . -false `
249         awk </dev/null 'BEGIN{ for (i=1;i<ARGC;i++) print " -o -iname *"ARGV[i]"*"; }' "$@"
250         `; }
251 function mkcd { mkdir -p "$1"; cd "$1"; }
252 function pushdmk { mkdir -p "$1"; pushd "$1"; }
253 function rsync {(unset rsync; n rsync -a -v -e ssh --progress --stats --inplace --rsync-path='nice -n20 ionice -c3 rsync' "$@"; );}
254 function tohex { od -An -txC|tr -d '\n '|tr 'a-f' 'A-F';echo; }
255 function edall {
256         find -type f|while read -r i;do
257                 (awk </dev/null 'BEGIN{ for (i=1;i<ARGC;i++) print ARGV[i]; }' "$@";echo -e 'w\nq')|ed -s "$i"
258                 done
259         }
260 function mi { (
261         set -ex;cd "$1";while true;do test "$PWD" != "/";if [ -e configure.in -o -e Makefile.PL ];then break;fi;cd ..;done;make install
262         ); }
263 function ctags {(unset ctags
264         if [ $# -ne 0 -a '(' $# -ne 1 -o "$1" '!=' "--c-types=+px" ')' ];then ctags "$@";else
265                 find -name testsuite -prune -o -name gdbserver -prune -o -name .pc -prune -o -name .svn -prune -o \
266                                 -type f -a '!' -name tags -a '!' -name TAGS -a '(' -false \
267                                                 -o -name "*.[chCy]" \
268                                                 -o -name "*.cc"    \
269                                                 -o -name "*.cxx"   \
270                                                 -o -name "*.cpp"   \
271                                                 -o -name "*.[Ss]"  \
272                                                 -o -name "*.java"  \
273                                                 -o -name "*.p[lm]" \
274                                                 -o -name "*.py" \
275                                                 -o -name "*.exp" \
276                                                 ')' \
277                                 |ctags --file-tags -L - --langmap=Tcl:+.exp "$@"
278         fi; );}
279 function ctagsh { ctags "--c-types=+px"; }
280 function cpan {(unset cpan; if [ $# = 0 ];then cpan;else perl -MCPAN -e "install qw($*);";fi; );}
281 function exx { cd "`unset exx;exx "$@"|tee /proc/self/fd/2|tail -n1|sed -n 's/^extdir=//p'`"; }
282 function debuginfo { if test -n "$*";then echo "$*";else cat;fi \
283         |xargs rpm -qf|xargs rpmquery --qf '%{SOURCERPM}\n'|sed 's/-[^-]*-[^-]*[.]src[.]rpm$/-debuginfo/'|sort -u; }
284 function ipcsrmall { ipcs|awk '/- Shared Memory/{x="-m"}/- Semaphore/{x="-s"}/^0x/{print "ipcrm "x" "$2}'; }
285 function eog {(unset eog; touch /tmp/eog.$$;eog "$@" {,,,,,,,,,}/tmp/eog.$$;rm -f /tmp/eog.$$; );}
286 function diffc { diff -dup "$@"|grep -v '^\(Only in \|Binary files\)'; }
287 function diffi { diffc -X ~/.diffi.list "$@" | diffdecvs; }
288 function cvs {(unset cvs
289         local _opts _opts_d _now _line _o
290         _opts_d="-d"
291         if grep -iw '\(sources.redhat.com\|sourceware.org\):/cvs/src' CVS/Root &>/dev/null;then _opts_d="";fi
292         if grep -iw '\(cvs.fedoraproject.org\):/cvs/pkgs' CVS/Root &>/dev/null;then _opts_d="";fi
293         if grep '^tests/kernel/syscalls/ptrace' CVS/Repository &>/dev/null;then _opts_d="";fi
294         _now=false
295         _line=""
296         _opts=""
297         while [ $# != 0 ];do
298                 _o="$1"
299                 shift
300                 _line="$_line $_o"
301                 if [ "$_o" = "--" ] && ! $_now;then _now=true;continue;fi
302                 if [ "${_o#-}" != "$_o" ] && ! $_now;then continue;fi
303                 if [ "$_o" = update -o "$_o" = upd -o "$_o" = up ];then _opts="$_opts_d";fi
304                 break
305                 done
306         cvs $_line $_opts "$@"
307         ); }
308 function perlrpm { repoquery -q --whatprovides $(for i in "$@";do echo "perl($i)";done|sed -e 's/\//::/g' -e 's/[.]pm//g'); }
309 # `-u' limits the search to $UID.
310 function pidof
311 {(unset pidof
312   if [ "$1" = "-u" ];then
313     shift
314     local r="$(pidof "$@")"
315     local space=""
316     local p
317     for p in $r;do
318       if grep -q "$(echo -e "^Uid:\t$UID\t")" "/proc/$p/status";then
319         echo -n "${space}$p"
320         space=" "
321       fi
322     done
323     echo
324   else
325     pidof "$@"
326   fi
327 )}
328 function sumlog { find "$@" ! -name config.log -name "*.log" -o -name "*.sum"; }
329 function sourcewarecvscheckout {(set -ex
330         ! test -d src
331         ! test -d $1-cvs 
332         (set +x;cvs -z3 -d :pserver:anoncvs:@sourceware.org:/cvs/src checkout $1)
333         mv src $1-cvs
334         cd $1-cvs
335         (set +x;cvs update)
336         #(set +x;cvsignoresall)
337         (set +x;ignoresall)
338         );}
339 function gdbgitclone { git clone git://sourceware.org/git/gdb.git gdb-git; }
340 function binutilsgitclone { git clone git://sourceware.org/git/binutils.git binutils-git; }
341 function archergitclone { git clone git://sourceware.org/git/archer.git archer-git; }
342 function gdbcvscheckout { sourcewarecvscheckout gdb; }
343 function binutilscvscheckout { sourcewarecvscheckout binutils; }
344 function uri_escape   { perl -MURI::Escape -le '$_=<>;chomp;print uri_escape   $_;'; };
345 function uri_unescape { perl -MURI::Escape -le '$_=<>;chomp;print uri_unescape $_;'; };
346 alias fetchmail='n fetchmail'
347 function rpmsrclist
348 {
349         if [ -z "$*" ]; then
350                 echo >&2 "rpmsrclist gcc-4.3.2-7 [4.4.0-0.25 [-|http://kojipkgs.fedoraproject.org/packages/gcc/4.4.0/0.25/]]"
351         else
352                 rpm -q --qf '%{SOURCERPM} %{name}-%{version}-%{release}.%{arch}\n' -a \
353                         | grep "^$1.src.rpm " | sed 's/^[^ ]* //' \
354                         | \
355                                 if [ -z "$2" ]; then \
356                                         cat; \
357                                 else \
358                                         sed "s/-$(echo "$1"|sed 's/^.*-\([^-]*-[^-]*\)$/\1/')/-$2/"
359                                 fi \
360                         | \
361                                 if [ -z "$3" ]; then \
362                                         cat; \
363                                 else \
364                                         if [ "$3" != - ]; then
365                                                 sed "s#.*#$3&.rpm#"; \
366                                         else \
367                                                 base="$(echo "$1"|sed 's/^\(.*\)-[^-]*-[^-]*$/\1/')"; \
368                                                 sed "s#^.*-\([^-]*\)-\([^-]*\)\.\([^.]*\)\$#http://kojipkgs.fedoraproject.org/packages/$base/\1/\2/\3/&.rpm#"; \
369                                         fi; \
370                                 fi \
371                         | sort -u
372         fi
373 }
374 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 "$@";);}
375 function yumupdate {(ulimit -v unlimited;yum makecache;yum -y --skip-broken update "$@";);}
376 function gitcommit { git commit -a -m .; }
377 function gpg {(unset gpg; http_proxy= all_proxy= HTTP_PROXY= ALL_PROXY= gpg "$@"; );}
378
379 ulimit -S -c 0
380 set +H
381 shopt -s mailwarn
382 unset OPTIND
383 umask 022
384
385 if [ -f "$HOME/.bashrc.local" ];then source "$HOME/.bashrc.local";fi
386
387 # Interactive part:
388 for key in $HOME/.ssh/id_dsa;do
389
390         # DISABLED now.
391         continue
392
393         [ -r "$key" ] || continue
394         # Do not: [ -n "$SSH_TTY" ] && continue
395         # as we may want foreign SSH keys too.
396
397         agenteval=/tmp/.$USER.ssh-agent.eval
398         if lockfile -1 -r 3 -l 10 -s 1 $agenteval.lock;then
399                 test -f $agenteval -a -O $agenteval -a -G $agenteval &&
400                                 # ">/dev/null" to prevent: echo Agent pid 31074
401                                 source $agenteval >/dev/null
402                 if [ "ssh-agent" != "`(xargs -0 </proc/"$SSH_AGENT_PID"/cmdline sh -c 'echo "$0"') 2>/dev/null `" ];then
403                         rm -f $agenteval
404                         (test ! -e $agenteval && ssh-agent -s >$agenteval) || echo >&2 'Failing ssh-agent!'
405                         # ">/dev/null" to prevent: echo Agent pid 31074
406                         source $agenteval >/dev/null
407                 fi
408                 rm -f $agenteval.lock
409         fi
410
411         # Prevent gdm(8) lockups on non-interactive consoles.
412         tty -s || continue
413         (ssh-add -l|grep -qw "$key") && continue
414         if lockfile -! -1 -r 0 $agenteval.input.lock 2>/dev/null;then
415                 echo >&2 -n "Locking: $agenteval.input.lock ... "
416                 lockfile -1 -r -1 $agenteval.input.lock
417                 echo >&2 "locked"
418         fi
419         # Recheck identity existence after the lock acquire
420         if ssh-add -l|grep -qw "$key";then
421                 echo >&2 "Identity $key already appended in the meantime."
422         else
423                 # "2>/dev/null" to prevent: Identity added: .ssh/id_dsa (.ssh/id_dsa)
424                 ssh-add "$key" 2>/dev/null
425         fi
426         rm -f $agenteval.input.lock
427         echo >&2 "$agenteval.input.lock unlocked."
428 done
429 unset agenteval
430
431         unset _home_short_dotbashrc     # permit later reinitializations
432 fi      # _home_short_dotbashrc
433
434 true    # Prevent crash in '-e' mode