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
10 export PERL5LIB="$HOME/perl5/lib/perl5/`uname -m`-linux-thread-multi:$HOME/perl5/lib/perl5";
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:
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;" "$@"; }
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
31 if [ -f /etc/bashrc ];then source /etc/bashrc;fi
33 _bash_profile_addpath_fini=""
34 function _bash_profile_addpath # <variablename>,<dirpathname>
36 local _varname _varval _varvalold _dirpathname _opt_f _opt_s
39 while getopts fs got;do
41 [fs]) eval "_opt_$got=1" ;;
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'"
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}\""
58 function _bash_profile_addpath_fini
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)}'`\""
64 unset -v _bash_profile_addpath_fini
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"
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"
101 unset -f _bash_profile_addpath
102 _bash_profile_addpath_fini
103 unset -f _bash_profile_addpath_fini
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 # /etc/profile.d/colorgrep.sh
116 unalias 2>/dev/null egrep # /etc/profile.d/colorgrep.sh
117 unalias 2>/dev/null fgrep # /etc/profile.d/colorgrep.sh
119 # Prevent processing of aliases during the parsing of this script file by
122 function grep {(unset grep; ( ulimitme; grep "$@"; ); );}
123 function ls {(unset ls; ( ls -bF "$@"; ); );}
124 function l { ls -lbF "$@"; }
125 if which vim &>/dev/null;then
128 echo >&2 "WARNING: No vim(1)."
130 function grepb { grep --binary-files=binary "$@"; }
131 function L { lynx "$@"; }
132 function chown {(unset chown; ( chown --no-dereference "$@"; ); );}
133 function chgrp {(unset chgrp; ( chgrp --no-dereference "$@"; ); );}
134 function hexedit {(unset hexedit; ( hexedit -s "$@"; ); );}
135 function cvs2cl {(unset cvs2cl; ( cvs2cl --window 3600 --separate-header --no-wrap "$@"; ); );}
136 function cvsfiles { cvsutil --files --print "$@"; }
137 function cvsignores { cvsutil --ignores --print "$@"; }
138 function cvsignoresall { cvsutil --ignores --workings --print "$@"; }
139 function cvsignoresrm { cvsutil --ignores --rm "$@"; }
140 function cvsignoresrmall { cvsutil --ignores --workings --rm "$@"; }
141 function cvsignoresallrm { cvsutil --ignores --workings --rm "$@"; }
142 function svnignoresall { svn status |sed -n "s/^[?] //p" "$@"; }
143 function svnignoresallrm { svn status |sed -n "s/^[?] //p"|tr "\n" "\0"|xargs -0 rm -rf "$@"; }
144 function ignores { find -name "*.orig" -o -name ".#*" -o -name "*~" "$@"; }
145 function ignoresrm { ignores "$@" | xargs rm -f; }
146 function ignoresall { ignores -o -name "*.rej" "$@"; }
147 function ignoresallrm { ignoresall "$@" | xargs rm -f; }
148 function disass { objdump -D --target=binary --architecture=i386:x86-64 "$@"; }
149 function disass32 { objdump -D --target=binary --architecture=i386 "$@"; }
150 function cal {(unset cal; ( cal -m "$@"; ); );}
151 function vncreadonly { vncviewer -FullColor -Shared -ViewOnly "$@"; }
152 function diff {(unset diff; ( diff -dup "$@"; ); );}
153 $(: MAKEFLAGS= - "make install" does not expect -j and .spec files do not force -j1.)
154 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" --with buildisa "$@"; rmdir &>/dev/null BUILDROOT; }
155 function gdbn { gdb -nx --command=~/.gdbinit "$@"; }
156 function hd { od -Ax -tx1; }
157 function wget {(unset wget; ( wget --no-check-certificate "$@"; ); );}
158 function ucwkbd { setxkbmap -layout us,cz -variant ,ucw -option grp:caps_switch; }
161 unset command_not_found_handle
162 shopt -u progcomp # Disable 'bash-completion' rpm
164 # '2>/dev/null' to prevent: TMOUT: readonly variable
165 [ -n "$SSH_TTY" ] && export TMOUT=900 2>/dev/null
167 #broken: [ -x /bin/less ] && export PAGER='/bin/less -rMMh5cis'
169 export PERL_LOCAL_LIB_ROOT="$HOME/perl5";
170 export PERL_MB_OPT="--install_base $HOME/perl5";
171 export PERL_MM_OPT="INSTALL_BASE=$HOME/perl5";
172 # Sometimes needed in non-interactive .bashrc.
173 # Unconditionally it would break quilt.
174 export PATH="$HOME/perl5/bin:$PATH";
176 for file in $HOME/.bookmarks.html;do
177 export WWW_HOME="file://$HOME/"
178 [ -r $file ] && export WWW_HOME="file://$file"
180 if echo x|grep --exclude=y -q x 2>/dev/null;then
181 alias grep='grep --exclude=tags --exclude=TAGS --exclude=ChangeLog* --exclude=*.svn-base --exclude=*~'
182 # FIXME: grep(1) ignores subdirectories for --exclude.
183 # --exclude=testsuite --exclude=.pc --exclude=.svn --exclude=CVS --exclude=po
185 if [ -n "$PS1" ];then # set only in interactive sessions
186 if [ ! -f /MOCK ];then
187 export PS1='[bash]${LOGNAME}@${HOSTNAME}:${PWD}# '
189 export PS1='[bash]${LOGNAME}@MOCK-'"`cat /MOCK`"':${PWD}# '
191 export PS1='\[\017\]'"$PS1" # \017=std charmap
192 export PS1='\[\033%G\]'"$PS1" # \033%G=utf-8
193 # Do not: kbd_mode -u # utf-8
194 # as it breaks keyboard state in X and it is not permitted for non-root.
196 export MINICOM="-m -c on" # metakeys+color
197 export HISTSIZE=10000000
198 export HISTFILESIZE="$HISTSIZE"
199 export GDBHISTFILE="$HOME/.gdb_history"
201 export TZ=":/usr/share/zoneinfo/Europe/Prague"
202 #export TZ=":/usr/share/zoneinfo/Canada/Eastern"
203 export PYTHONUNBUFFERED=1
204 export ASAN_OPTIONS=detect_leaks=0
206 cpus="`getconf _NPROCESSORS_ONLN`"
207 if [ -n "$cpus" ];then
208 # *3/2 was OOM for host1 32 CPUs + 16GB RAM
209 # *1 was OOM for host1 ccache -C;touch gui.h;time make all
210 # *3/4 was also OOM with KVM running
211 # *1/2 was OK for host1 32 CPUs + 16GB RAM
212 MAKEFLAGS="$MAKEFLAGS -j$[$cpus*1]"
215 # Do not: grep -w "$TERM" /etc/termcap >/dev/null || export TERM=vt220
216 # as Sun workaround as Debian misses: /etc/termcap
218 [ "$TERM" = vt220 -a "${uname_p%86}" != "$uname_p" ] && export TERM=linux
219 if grep 2>/dev/null -q '^..............:0C38 00000000:0000 0A ' /proc/net/tcp \
220 || grep 2>/dev/null -q '^....: 00000000000000000000000000000000:0C38 00000000000000000000000000000000:0000 0A ' /proc/net/tcp6 \
222 export http_proxy=http://127.0.0.1:3128/
223 export https_proxy=http://127.0.0.1:3128/
224 export ftp_proxy=http://127.0.0.1:3128/
227 [ "$_selfabs" = "${_selfabs#/}" ] && _selfabs="$BASH_SOURCE"
228 [ "$_selfabs" = "${_selfabs#/}" ] && _selfabs="$PWD/.bashrc"
229 [ -r "$_selfabs" ] || unset _selfabs
230 [ -n "$_selfabs" ] && export VIMINIT="source `echo "$_selfabs"|sed 's/[.]bashrc$/.vimrc/'`"
233 unset LANG LANGUAGE `set|sed -n 's/^\(LC_[^=]*\)=.*$/\1/p'`
234 export LANG=en_US.UTF-8
235 # Force strcoll() to sort case-sensitively! (empty/undef doesn't work)
237 # Do not: # Prevent: perl: warning: Setting locale failed.
238 # # due to LC_COLLATE=C and LC_ALL=(unset)
240 # as it breaks Mutt "utf-8" and somehow it is no longer needed.
241 # Re: [Bug-readline] Readline 6.0 patch 004 trapped signal echoed to conso
242 # http://lists.gnu.org/archive/html/bug-readline/2009-09/msg00006.html
243 # 2>/dev/null for possible: stty: standard input: Inappropriate ioctl for device
244 stty -echoctl 2>/dev/null
245 export GIT_MERGE_AUTOEDIT=no
247 function wclines { awk '{x[$0]++}END{for (i in x) print x[i]"\t"i}'; }
248 # SunOS does not support "-m"
249 export ULIMITME_OPTS=""
250 for i in "-m 100000" "-d 150000" "-v 200000";do
251 (ulimit $i 2>/dev/null) && ULIMITME_OPTS="$ULIMITME_OPTS $i"
253 # Prevent: ulimit: -m 100000 -d 150000 -v 200000: invalid number
254 # by forcing our known $IFS value; eval(1) is needed to take $IFS to effect:
255 function ulimitme { IFS=" " eval "ulimit $ULIMITME_OPTS"; }
256 function finame { find . -false `
257 awk </dev/null 'BEGIN{ for (i=1;i<ARGC;i++) print " -o -iname *"ARGV[i]"*"; }' "$@"
259 function mkcd { mkdir -p "$1"; cd "$1"; }
260 function pushdmk { mkdir -p "$1"; pushd "$1"; }
261 function rsync {(unset rsync; n rsync -c -a -v -e ssh --progress --stats --inplace --rsync-path='nice -n20 ionice -c3 rsync' "$@"; );}
262 function tohex { od -An -txC|tr -d '\n '|tr 'a-f' 'A-F';echo; }
264 find -type f|while read -r i;do
265 (awk </dev/null 'BEGIN{ for (i=1;i<ARGC;i++) print ARGV[i]; }' "$@";echo -e 'w\nq')|ed -s "$i"
269 set -ex;cd "$1";while true;do test "$PWD" != "/";if [ -e configure.in -o -e Makefile.PL ];then break;fi;cd ..;done;make install
271 function ctags {(unset ctags
272 if [ $# -ne 0 -a '(' $# -ne 1 -o "$1" '!=' "--c-types=+px" ')' ];then ctags "$@";else
273 find -name testsuite -prune -o -name gdbserver -prune -o -name .pc -prune -o -name .svn -prune -o \
274 -type f -a '!' -name tags -a '!' -name TAGS -a '(' -false \
275 -o -name "*.[chCy]" \
285 |ctags --file-tags -L - --langmap=Tcl:+.exp "$@"
287 function ctagsh { ctags "--c-types=+px"; }
288 function cpan {(unset cpan; if [ $# = 0 ];then cpan;else perl -MCPAN -e "install qw($*);";fi; );}
289 function exx { cd "`unset exx;exx "$@"|tee /proc/self/fd/2|tail -n1|sed -n 's/^extdir=//p'`"; }
290 function debuginfo { if test -n "$*";then echo "$*";else cat;fi \
291 |xargs rpm -qf|xargs rpmquery --qf '%{SOURCERPM}\n'|sed 's/-[^-]*-[^-]*[.]src[.]rpm$/-debuginfo/'|sort -u; }
292 function ipcsrmall { ipcs|awk '/- Shared Memory/{x="-m"}/- Semaphore/{x="-s"}/^0x/{print "ipcrm "x" "$2}'; }
293 function eog {(unset eog; touch /tmp/eog.$$;eog "$@" {,,,,,,,,,}/tmp/eog.$$;rm -f /tmp/eog.$$; );}
294 function diffc { diff -dup "$@"|grep -v '^\(Only in \|Binary files\)'; }
295 function diffi { diffc -X ~/.diffi.list "$@" | diffdecvs; }
296 function cvs {(unset cvs
297 local _opts _opts_d _now _line _o
299 if grep -iw '\(sources.redhat.com\|sourceware.org\):/cvs/src' CVS/Root &>/dev/null;then _opts_d="";fi
300 if grep -iw '\(cvs.fedoraproject.org\):/cvs/pkgs' CVS/Root &>/dev/null;then _opts_d="";fi
301 if grep '^tests/kernel/syscalls/ptrace' CVS/Repository &>/dev/null;then _opts_d="";fi
309 if [ "$_o" = "--" ] && ! $_now;then _now=true;continue;fi
310 if [ "${_o#-}" != "$_o" ] && ! $_now;then continue;fi
311 if [ "$_o" = update -o "$_o" = upd -o "$_o" = up ];then _opts="$_opts_d";fi
314 cvs $_line $_opts "$@"
316 function perlrpm { repoquery -q --whatprovides $(for i in "$@";do echo "perl($i)";done|sed -e 's/\//::/g' -e 's/[.]pm//g'); }
317 # `-u' limits the search to $UID.
320 if [ "$1" = "-u" ];then
322 local r="$(pidof "$@")"
326 if grep -q "$(echo -e "^Uid:\t$UID\t")" "/proc/$p/status";then
336 function sumlog { find "$@" ! -name config.log -name "*.log" -o -name "*.sum"; }
337 function sourcewarecvscheckout {(set -ex
340 (set +x;cvs -z3 -d :pserver:anoncvs:@sourceware.org:/cvs/src checkout $1)
344 #(set +x;cvsignoresall)
347 function gdbgitclone { git clone git://sourceware.org/git/binutils-gdb.git gdb-git; }
348 function archergitclone { git clone git://sourceware.org/git/archer.git archer-git; }
349 function gdbcvscheckout { sourcewarecvscheckout gdb; }
350 function binutilscvscheckout { sourcewarecvscheckout binutils; }
351 function uri_escape { perl -MURI::Escape -le '$_=<>;chomp;print uri_escape $_;'; };
352 function uri_unescape { perl -MURI::Escape -le '$_=<>;chomp;print uri_unescape $_;'; };
353 alias fetchmail='n fetchmail'
357 echo >&2 "rpmsrclist gcc-4.3.2-7 [4.4.0-0.25 [-|http://kojipkgs.fedoraproject.org/packages/gcc/4.4.0/0.25/]]"
359 rpm -q --qf '%{SOURCERPM} %{name}-%{version}-%{release}.%{arch}\n' -a \
360 | grep "^$1.src.rpm " | sed 's/^[^ ]* //' \
362 if [ -z "$2" ]; then \
365 sed "s/-$(echo "$1"|sed 's/^.*-\([^-]*-[^-]*\)$/\1/')/-$2/"
368 if [ -z "$3" ]; then \
371 if [ "$3" != - ]; then
372 sed "s#.*#$3&.rpm#"; \
374 base="$(echo "$1"|sed 's/^\(.*\)-[^-]*-[^-]*$/\1/')"; \
375 sed "s#^.*-\([^-]*\)-\([^-]*\)\.\([^.]*\)\$#http://kojipkgs.fedoraproject.org/packages/$base/\1/\2/\3/&.rpm#"; \
381 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 "$@";);}
382 function yumupdate {(ulimit -v unlimited;yum makecache;yum -y --skip-broken update "$@";);}
383 function gitcommit { git commit -a -m .; }
384 function gpg {(unset gpg; http_proxy= all_proxy= HTTP_PROXY= ALL_PROXY= gpg "$@"; );}
393 if [ -f "$HOME/.bashrc.local" ];then source "$HOME/.bashrc.local";fi
396 for key in $HOME/.ssh/id_dsa;do
401 [ -r "$key" ] || continue
402 # Do not: [ -n "$SSH_TTY" ] && continue
403 # as we may want foreign SSH keys too.
405 agenteval=/tmp/.$USER.ssh-agent.eval
406 if lockfile -1 -r 3 -l 10 -s 1 $agenteval.lock;then
407 test -f $agenteval -a -O $agenteval -a -G $agenteval &&
408 # ">/dev/null" to prevent: echo Agent pid 31074
409 source $agenteval >/dev/null
410 if [ "ssh-agent" != "`(xargs -0 </proc/"$SSH_AGENT_PID"/cmdline sh -c 'echo "$0"') 2>/dev/null `" ];then
412 (test ! -e $agenteval && ssh-agent -s >$agenteval) || echo >&2 'Failing ssh-agent!'
413 # ">/dev/null" to prevent: echo Agent pid 31074
414 source $agenteval >/dev/null
416 rm -f $agenteval.lock
419 # Prevent gdm(8) lockups on non-interactive consoles.
421 (ssh-add -l|grep -qw "$key") && continue
422 if lockfile -! -1 -r 0 $agenteval.input.lock 2>/dev/null;then
423 echo >&2 -n "Locking: $agenteval.input.lock ... "
424 lockfile -1 -r -1 $agenteval.input.lock
427 # Recheck identity existence after the lock acquire
428 if ssh-add -l|grep -qw "$key";then
429 echo >&2 "Identity $key already appended in the meantime."
431 # "2>/dev/null" to prevent: Identity added: .ssh/id_dsa (.ssh/id_dsa)
432 ssh-add "$key" 2>/dev/null
434 rm -f $agenteval.input.lock
435 echo >&2 "$agenteval.input.lock unlocked."
439 unset _home_short_dotbashrc # permit later reinitializations
440 fi # _home_short_dotbashrc
442 true # Prevent crash in '-e' mode