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 if grep 2>/dev/null -q '^..............:0C38 00000000:0000 0A ' /proc/net/tcp \
13 || grep 2>/dev/null -q '^....: 00000000000000000000000000000000:0C38 00000000000000000000000000000000:0000 0A ' /proc/net/tcp6 \
15 export http_proxy=http://127.0.0.1:3128/
16 export https_proxy=http://127.0.0.1:3128/
17 export ftp_proxy=http://127.0.0.1:3128/
20 # "$PS1" for interactive shells detection.
21 if [ -n "$PS1" -a -z "$_home_short_dotbashrc" ];then
22 # We permit later reinitialization by unsetting it.
23 # During our execution we forbid spawning to prevent deadlock by:
25 # . /etc/profile.d/lang.sh
26 # unicode_start iso02.08
27 export _home_short_dotbashrc=true
28 # $TERM gets restored to its 'norc-' state after ~/.bashrc
29 # alias norc='TERM="norc-$TERM" ssh -t -o 'NoHostAuthenticationForLocalhost yes' $USER@localhost "cd $PWD; TERM=$TERM;"'
30 function norc { TERM="norc-$TERM" ssh -t -o 'NoHostAuthenticationForLocalhost yes' $USER@localhost "cd $PWD; TERM=$TERM;" "$@"; }
32 # Fix $USER and $LOGNAME (not $MAIL) for /etc/passwd line:
33 # root-lace:x:0:0:root for Jan Kratochvil:/home/root-lace:/bin/bash
34 if [ "$UID" -eq 0 -a "$USER" = "root" -a "$HOME" != "${HOME#*/root-}" ];then
39 if [ -f /etc/bashrc ];then source /etc/bashrc;fi
41 _bash_profile_addpath_fini=""
42 function _bash_profile_addpath # <variablename>,<dirpathname>
44 local _varname _varval _varvalold _dirpathname _opt_f _opt_s
47 while getopts fs got;do
49 [fs]) eval "_opt_$got=1" ;;
53 eval "_varname=\"\$$[$OPTIND+0]\""
54 eval "_dirpathname=\"\$$[$OPTIND+1]\""
55 if [ $_opt_f = 0 -a '!' -d "$_dirpathname" ];then return;fi
56 if [ $_opt_s = 1 -o -z "`eval "echo \\${$_varname}"`" ];then
57 eval "$_varname='$_dirpathname'"
59 # We want to prevent duplicates due to .bashrc reentrancy across fork(2)s. It is array!
60 _bash_profile_addpath_fini="$_bash_profile_addpath_fini $_varname"
61 # We want to override any original directories, place dirpathname first!
62 eval "$_varname=\"$_dirpathname:\${$_varname}\""
66 function _bash_profile_addpath_fini
69 for _varname in `echo "$_bash_profile_addpath_fini"|tr ' ' '\n'|sort -u`;do
70 eval "$_varname=\"`eval $(echo "echo \"\\$$_varname\"")|awk -v RS=':' '/[^\n]/{if (!x[$0]++) e=e":"$0;}END{print substr(e,2)}'`\""
72 unset -v _bash_profile_addpath_fini
75 # Use reverse order of preferred directories:
76 # gid(1) dependency on: /opt/sfw/bin
77 # EUID="`id -u 2>/dev/null || /usr/xpg4/bin/id -u 2>/dev/null || gid -u`"
78 _bash_profile_addpath -f PATH "/sbin"
79 _bash_profile_addpath -f PATH "/usr/sbin"
80 _bash_profile_addpath -f PATH "/bin"
81 _bash_profile_addpath -f PATH "/usr/bin"
82 _bash_profile_addpath PATH "/usr/lib/ccache"
83 _bash_profile_addpath PATH "/usr/lib64/ccache"
84 [ $EUID -eq 0 ] && _bash_profile_addpath -f PATH "/usr/local/sbin"
85 _bash_profile_addpath -f PATH "/usr/local/bin"
86 _bash_profile_addpath -f MANPATH "/usr/X11R6/man"
87 _bash_profile_addpath -f MANPATH "/usr/share/man"
88 _bash_profile_addpath -f MANPATH "/usr/local/man"
89 _bash_profile_addpath -s JAVA_HOME "/usr/java"
90 _bash_profile_addpath -s JAVA_HOME "/usr/local/java"
91 uname_p="`uname -p 2>/dev/null || uname -m`"
92 for family in $HOME;do
93 for arch in $family $family/$uname_p;do
94 # Do not "-f": We use /net !
95 _bash_profile_addpath PATH "$arch/bin"
96 _bash_profile_addpath -s JAVA_HOME "$arch/java"
97 [ $EUID -eq 0 ] && _bash_profile_addpath PATH "$arch/sbin"
98 _bash_profile_addpath LD_LIBRARY_PATH "$arch/lib64"
99 _bash_profile_addpath LD_LIBRARY_PATH "$arch/lib"
100 _bash_profile_addpath MANPATH "$arch/man"
103 _bash_profile_addpath -f -s CVSROOT ":pserver:pserver:@cvs.jankratochvil.net/cvs" # default
104 [ -n "$JAVA_HOME" ] && _bash_profile_addpath PATH "$JAVA_HOME/bin"
105 _bash_profile_addpath -s CVSROOT "$HOME/pserver/cvs"
106 _bash_profile_addpath -s CVSROOT "$HOME/cvs"
107 _bash_profile_addpath -s ANT_HOME "/usr/local/ant"
109 unset -f _bash_profile_addpath
110 _bash_profile_addpath_fini
111 unset -f _bash_profile_addpath_fini
113 # '2>/dev/null' to prevent: unalias: x: not found
114 # It must be run before `function's below as otherwise it would get embedded.
115 unalias 2>/dev/null cp # -i
116 unalias 2>/dev/null mv # -i
117 unalias 2>/dev/null rm # -i
118 unalias 2>/dev/null df # -h
119 unalias 2>/dev/null du # -h
120 unalias 2>/dev/null ls # --color=auto
121 unalias 2>/dev/null l. # ls -d .* --color=auto
122 unalias 2>/dev/null ll # ls -l --color=auto
123 unalias 2>/dev/null grep # /etc/profile.d/colorgrep.sh
124 unalias 2>/dev/null egrep # /etc/profile.d/colorgrep.sh
125 unalias 2>/dev/null fgrep # /etc/profile.d/colorgrep.sh
127 # Prevent processing of aliases during the parsing of this script file by
130 function grep {(unset grep; ( ulimitme; grep "$@"; ); );}
131 function ls {(unset ls; ( ls -bF "$@"; ); );}
132 function l { ls -lbF "$@"; }
133 if which vim &>/dev/null;then
136 echo >&2 "WARNING: No vim(1)."
138 function grepb { grep --binary-files=binary "$@"; }
139 function L { lynx "$@"; }
140 function chown {(unset chown; ( chown --no-dereference "$@"; ); );}
141 function chgrp {(unset chgrp; ( chgrp --no-dereference "$@"; ); );}
142 function hexedit {(unset hexedit; ( hexedit -s "$@"; ); );}
143 function cvs2cl {(unset cvs2cl; ( cvs2cl --window 3600 --separate-header --no-wrap "$@"; ); );}
144 function cvsfiles { cvsutil --files --print "$@"; }
145 function cvsignores { cvsutil --ignores --print "$@"; }
146 function cvsignoresall { cvsutil --ignores --workings --print "$@"; }
147 function cvsignoresrm { cvsutil --ignores --rm "$@"; }
148 function cvsignoresrmall { cvsutil --ignores --workings --rm "$@"; }
149 function cvsignoresallrm { cvsutil --ignores --workings --rm "$@"; }
150 function svnignoresall { svn status |sed -n "s/^[?] //p" "$@"; }
151 function svnignoresallrm { svn status |sed -n "s/^[?] //p"|tr "\n" "\0"|xargs -0 rm -rf "$@"; }
152 function ignores { find -name "*.orig" -o -name ".#*" -o -name "*~" "$@"; }
153 function ignoresrm { ignores "$@" | xargs rm -f; }
154 function ignoresall { ignores -o -name "*.rej" "$@"; }
155 function ignoresallrm { ignoresall "$@" | xargs rm -f; }
156 function disass { objdump -D --target=binary --architecture=i386:x86-64 "$@"; }
157 function disass32 { objdump -D --target=binary --architecture=i386 "$@"; }
158 function cal {(unset cal; ( cal -m "$@"; ); );}
159 function vncreadonly { vncviewer -FullColor -Shared -ViewOnly "$@"; }
160 function diff {(unset diff; ( diff -dup "$@"; ); );}
161 $(: MAKEFLAGS= - "make install" does not expect -j and .spec files do not force -j1.)
162 function rpmbuildlocal { time 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; }
163 function gdbn { gdb -nx --command=~/.gdbinit "$@"; }
164 function hd { od -Ax -tx1; }
165 function wget {(unset wget; ( wget --no-check-certificate "$@"; ); );}
166 function ucwkbd { setxkbmap -layout us,cz -variant ,ucw -option grp:caps_switch; }
167 function gdb {(unset gdb; ( gdb -q "$@"; ); );}
170 unset command_not_found_handle
171 shopt -u progcomp # Disable 'bash-completion' rpm
173 # '2>/dev/null' to prevent: TMOUT: readonly variable
174 [ -n "$SSH_TTY" ] && export TMOUT=900 2>/dev/null
176 #broken: [ -x /bin/less ] && export PAGER='/bin/less -rMMh5cis'
178 export PERL_LOCAL_LIB_ROOT="$HOME/perl5";
179 export PERL_MB_OPT="--install_base $HOME/perl5";
180 export PERL_MM_OPT="INSTALL_BASE=$HOME/perl5";
181 # Sometimes needed in non-interactive .bashrc.
182 # Unconditionally it would break quilt.
183 export PATH="$HOME/perl5/bin:$PATH";
185 for file in $HOME/.bookmarks.html;do
186 export WWW_HOME="file://$HOME/"
187 [ -r $file ] && export WWW_HOME="file://$file"
189 if echo x|grep --exclude=y -q x 2>/dev/null;then
190 alias grep='grep --exclude=tags --exclude=TAGS --exclude=ChangeLog* --exclude=*.svn-base --exclude=*~'
191 # FIXME: grep(1) ignores subdirectories for --exclude.
192 # --exclude=testsuite --exclude=.pc --exclude=.svn --exclude=CVS --exclude=po
194 if [ -n "$PS1" ];then # set only in interactive sessions
195 if [ ! -f /MOCK ];then
196 export PS1='[bash]${LOGNAME}@${HOSTNAME}:${PWD}# '
198 export PS1='[bash]${LOGNAME}@MOCK-'"`cat /MOCK`"':${PWD}# '
200 export PS1='\[\017\]'"$PS1" # \017=std charmap
201 if [ "${SHELL#*/com.termux/}" = "$SHELL" -a "${SSH_CLIENT#2a02:2b88:6:3b57::8f }" = "$SSH_CLIENT" ];then
202 export PS1='\[\033%G\]'"$PS1" # \033%G=utf-8
204 # Do not: kbd_mode -u # utf-8
205 # as it breaks keyboard state in X and it is not permitted for non-root.
207 export MINICOM="-m -c on" # metakeys+color
208 export HISTSIZE=10000000
209 export HISTFILESIZE="$HISTSIZE"
210 export GDBHISTFILE="$HOME/.gdb_history"
212 export TZ="Europe/Prague"
213 #export TZ="Canada/Eastern"
214 export PYTHONUNBUFFERED=1
215 export ASAN_OPTIONS=detect_leaks=0
216 export GTK_OVERLAY_SCROLLING=0
218 export DEBUGINFOD_URLS=
219 cpus="`getconf _NPROCESSORS_ONLN`"
220 if [ -n "$cpus" ];then
221 # *3/2 was OOM for host1 32 CPUs + 16GB RAM
222 # *1 was OOM for host1 ccache -C;touch gui.h;time make all
223 # *3/4 was also OOM with KVM running
224 # *1/2 was OK for host1 32 CPUs + 16GB RAM
225 MAKEFLAGS="$MAKEFLAGS -j$[$cpus*1]"
228 if (which icecc && pidof iceccd) &>/dev/null;then
229 export CCACHE_PREFIX=icecc
231 # Do not: grep -w "$TERM" /etc/termcap >/dev/null || export TERM=vt220
232 # as Sun workaround as Debian misses: /etc/termcap
234 [ "$TERM" = vt220 -a "${uname_p%86}" != "$uname_p" ] && export TERM=linux
236 [ "$_selfabs" = "${_selfabs#/}" ] && _selfabs="$BASH_SOURCE"
237 [ "$_selfabs" = "${_selfabs#/}" ] && _selfabs="$PWD/.bashrc"
238 [ -r "$_selfabs" ] || unset _selfabs
239 [ -n "$_selfabs" ] && export VIMINIT="source `echo "$_selfabs"|sed 's/[.]bashrc$/.vimrc/'`"
242 unset LANG LANGUAGE `set|sed -n 's/^\(LC_[^=]*\)=.*$/\1/p'`
243 export LANG=en_US.UTF-8
244 # Force strcoll() to sort case-sensitively! (empty/undef doesn't work)
246 # Do not: # Prevent: perl: warning: Setting locale failed.
247 # # due to LC_COLLATE=C and LC_ALL=(unset)
249 # as it breaks Mutt "utf-8" and somehow it is no longer needed.
250 # Re: [Bug-readline] Readline 6.0 patch 004 trapped signal echoed to conso
251 # http://lists.gnu.org/archive/html/bug-readline/2009-09/msg00006.html
252 # 2>/dev/null for possible: stty: standard input: Inappropriate ioctl for device
253 stty -echoctl 2>/dev/null
254 export GIT_MERGE_AUTOEDIT=no
256 function wclines { awk '{x[$0]++}END{for (i in x) print x[i]"\t"i}'; }
257 # SunOS does not support "-m"
258 export ULIMITME_OPTS=""
259 for i in "-v 2000000";do
260 (ulimit $i 2>/dev/null) && ULIMITME_OPTS="$ULIMITME_OPTS $i"
262 if [ -z "$ULIMITME_OPTS" ];then
263 # MinGW64 would be printing "unlimited" on each ulimitme() execution.
264 ULIMITME_OPTS="-v unlimited"
266 # Prevent: ulimit: -m 100000 -d 150000 -v 200000: invalid number
267 # by forcing our known $IFS value; eval(1) is needed to take $IFS to effect:
268 function ulimitme { IFS=" " eval "ulimit 2>/dev/null $ULIMITME_OPTS"; }
269 function finame { find . -false `
270 awk </dev/null 'BEGIN{ for (i=1;i<ARGC;i++) print " -o -iname *"ARGV[i]"*"; }' "$@"
272 function mkcd { mkdir -p "$1"; cd "$1"; }
273 function pushdmk { mkdir -p "$1"; pushd "$1"; }
274 function rsync {(unset rsync; n rsync -c -a -v -e ssh --progress --stats --inplace --rsync-path='nice -n20 ionice -c3 rsync' "$@"; );}
275 function tohex { od -An -txC|tr -d '\n '|tr 'a-f' 'A-F';echo; }
277 find -type f|while read -r i;do
278 (awk </dev/null 'BEGIN{ for (i=1;i<ARGC;i++) print ARGV[i]; }' "$@";echo -e 'w\nq')|ed -s "$i"
282 set -ex;cd "$1";while true;do test "$PWD" != "/";if [ -e configure.in -o -e Makefile.PL ];then break;fi;cd ..;done;make install
284 function ctags {(unset ctags
285 if [ $# -ne 0 -a '(' $# -ne 1 -o "$1" '!=' "--c-types=+px" ')' ];then ctags "$@";else
286 find -name testsuite -prune -o -name gdbserver -prune -o -name .pc -prune -o -name .svn -prune -o \
287 -type f -a '!' -name tags -a '!' -name TAGS -a '(' -false \
288 -o -name "*.[chCy]" \
291 -o -name "*.[ch]pp" \
298 |ctags --extras=+f -L - --langmap=Tcl:+.exp "$@"
300 function ctagsh { ctags "--c-types=+px"; }
301 function cpan {(unset cpan; if [ $# = 0 ];then cpan;else perl -MCPAN -e "install qw($*);";fi; );}
302 function exx { cd "`unset exx;exx "$@"|tee /proc/self/fd/2|tail -n1|sed -n 's/^extdir=//p'`"; }
303 function debuginfo { if test -n "$*";then echo "$*";else cat;fi \
304 |xargs rpm -qf|xargs rpmquery --qf '%{SOURCERPM}\n'|sed 's/-[^-]*-[^-]*[.]src[.]rpm$/-debuginfo/'|sort -u; }
305 function ipcsrmall { ipcs|awk '/- Shared Memory/{x="-m"}/- Semaphore/{x="-s"}/^0x/{print "ipcrm "x" "$2}'; }
306 function eog {(unset eog; touch /tmp/eog.$$;eog "$@" {,,,,,,,,,}/tmp/eog.$$;rm -f /tmp/eog.$$; );}
307 function diffc { diff -dup "$@"|grep -v '^\(Only in \|Binary files\)'; }
308 function diffi { diffc -X ~/.diffi.list "$@" | diffdecvs; }
309 function cvs {(unset cvs
310 local _opts _opts_d _now _line _o
312 if grep -iw '\(sources.redhat.com\|sourceware.org\):/cvs/src' CVS/Root &>/dev/null;then _opts_d="";fi
313 if grep -iw '\(cvs.fedoraproject.org\):/cvs/pkgs' CVS/Root &>/dev/null;then _opts_d="";fi
314 if grep '^tests/kernel/syscalls/ptrace' CVS/Repository &>/dev/null;then _opts_d="";fi
322 if [ "$_o" = "--" ] && ! $_now;then _now=true;continue;fi
323 if [ "${_o#-}" != "$_o" ] && ! $_now;then continue;fi
324 if [ "$_o" = update -o "$_o" = upd -o "$_o" = up ];then _opts="$_opts_d";fi
327 cvs $_line $_opts "$@"
329 function perlrpm { repoquery -q --whatprovides $(for i in "$@";do echo "perl($i)";done|sed -e 's/\//::/g' -e 's/[.]pm//g'); }
330 # `-u' limits the search to $UID.
333 if [ "$1" = "-u" ];then
335 local r="$(pidof "$@")"
339 if grep -q "$(echo -e "^Uid:\t$UID\t")" "/proc/$p/status";then
349 function sumlog { find "$@" ! -name config.log -name "*.log" -o -name "*.sum"; }
350 function sourcewarecvscheckout {(set -ex
353 (set +x;cvs -z3 -d :pserver:anoncvs:@sourceware.org:/cvs/src checkout $1)
357 #(set +x;cvsignoresall)
360 function gdbgitclone { git clone git://sourceware.org/git/binutils-gdb.git gdb-git; }
361 function archergitclone { git clone git://sourceware.org/git/archer.git archer-git; }
362 function gdbcvscheckout { sourcewarecvscheckout gdb; }
363 function binutilscvscheckout { sourcewarecvscheckout binutils; }
364 function uri_escape { perl -MURI::Escape -le '$_=<>;chomp;print uri_escape $_;'; };
365 function uri_unescape { perl -MURI::Escape -le '$_=<>;chomp;print uri_unescape $_;'; };
366 alias fetchmail='n fetchmail'
367 function sleep_until { (set -x;sleep $[$(date -d "$*" +%s)-$(date +%s)]); }
371 echo >&2 "rpmsrclist gcc-4.3.2-7 [4.4.0-0.25 [-|http://kojipkgs.fedoraproject.org/packages/gcc/4.4.0/0.25/]]"
373 rpm -q --qf '%{SOURCERPM} %{name}-%{version}-%{release}.%{arch}\n' -a \
374 | grep "^$1.src.rpm " | sed 's/^[^ ]* //' \
376 if [ -z "$2" ]; then \
379 sed "s/-$(echo "$1"|sed 's/^.*-\([^-]*-[^-]*\)$/\1/')/-$2/"
382 if [ -z "$3" ]; then \
385 if [ "$3" != - ]; then
386 sed "s#.*#$3&.rpm#"; \
388 base="$(echo "$1"|sed 's/^\(.*\)-[^-]*-[^-]*$/\1/')"; \
389 sed "s#^.*-\([^-]*\)-\([^-]*\)\.\([^.]*\)\$#http://kojipkgs.fedoraproject.org/packages/$base/\1/\2/\3/&.rpm#"; \
395 function yumupdate {(ulimit -v unlimited;yum makecache;yum -y --skip-broken update "$@";);}
396 function gitcommit { git commit -a --allow-empty-message -m '' "$@"; }
397 function gpg {(unset gpg; http_proxy= all_proxy= HTTP_PROXY= ALL_PROXY= gpg "$@"; );}
398 function swap() {( set -ex;local TMPFILE=tmp.$$;[ $# = 2 ] && mv "$1" $TMPFILE && mv "$2" "$1" && mv $TMPFILE "$2" && echo done )}
399 alias gthumb='rm -rf ~/.cache/thumbnails/fail/;gthumb'
404 #RHEL6->7 breaks: echo spa\ ce ~/foo<tab>
409 if [ -f "$HOME/.bashrc.local" ];then source "$HOME/.bashrc.local";fi
412 for key in $HOME/.ssh/id_dsa;do
417 [ -r "$key" ] || continue
418 # Do not: [ -n "$SSH_TTY" ] && continue
419 # as we may want foreign SSH keys too.
421 agenteval=/tmp/.$USER.ssh-agent.eval
422 if lockfile -1 -r 3 -l 10 -s 1 $agenteval.lock;then
423 test -f $agenteval -a -O $agenteval -a -G $agenteval &&
424 # ">/dev/null" to prevent: echo Agent pid 31074
425 source $agenteval >/dev/null
426 if [ "ssh-agent" != "`(xargs -0 </proc/"$SSH_AGENT_PID"/cmdline sh -c 'echo "$0"') 2>/dev/null `" ];then
428 (test ! -e $agenteval && ssh-agent -s >$agenteval) || echo >&2 'Failing ssh-agent!'
429 # ">/dev/null" to prevent: echo Agent pid 31074
430 source $agenteval >/dev/null
432 rm -f $agenteval.lock
435 # Prevent gdm(8) lockups on non-interactive consoles.
437 (ssh-add -l|grep -qw "$key") && continue
438 if lockfile -! -1 -r 0 $agenteval.input.lock 2>/dev/null;then
439 echo >&2 -n "Locking: $agenteval.input.lock ... "
440 lockfile -1 -r -1 $agenteval.input.lock
443 # Recheck identity existence after the lock acquire
444 if ssh-add -l|grep -qw "$key";then
445 echo >&2 "Identity $key already appended in the meantime."
447 # "2>/dev/null" to prevent: Identity added: .ssh/id_dsa (.ssh/id_dsa)
448 ssh-add "$key" 2>/dev/null
450 rm -f $agenteval.input.lock
451 echo >&2 "$agenteval.input.lock unlocked."
455 unset _home_short_dotbashrc # permit later reinitializations
456 fi # _home_short_dotbashrc
458 true # Prevent crash in '-e' mode