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 if ls -d -bF / &>/dev/null;then
132 function ls {(unset ls; ( ls -bF "$@"; ); );}
135 function ls {(unset ls; ( ls "$@"; ); );}
137 function l { ls -l "$@"; }
138 if which vim &>/dev/null;then
141 echo >&2 "WARNING: No vim(1)."
143 function grepb { grep --binary-files=binary "$@"; }
144 function L { lynx "$@"; }
145 function chown {(unset chown; ( chown --no-dereference "$@"; ); );}
146 function chgrp {(unset chgrp; ( chgrp --no-dereference "$@"; ); );}
147 function hexedit {(unset hexedit; ( hexedit -s "$@"; ); );}
148 function cvs2cl {(unset cvs2cl; ( cvs2cl --window 3600 --separate-header --no-wrap "$@"; ); );}
149 function cvsfiles { cvsutil --files --print "$@"; }
150 function cvsignores { cvsutil --ignores --print "$@"; }
151 function cvsignoresall { cvsutil --ignores --workings --print "$@"; }
152 function cvsignoresrm { cvsutil --ignores --rm "$@"; }
153 function cvsignoresrmall { cvsutil --ignores --workings --rm "$@"; }
154 function cvsignoresallrm { cvsutil --ignores --workings --rm "$@"; }
155 function svnignoresall { svn status |sed -n "s/^[?] //p" "$@"; }
156 function svnignoresallrm { svn status |sed -n "s/^[?] //p"|tr "\n" "\0"|xargs -0 rm -rf "$@"; }
157 function ignores { find -name "*.orig" -o -name ".#*" -o -name "*~" "$@"; }
158 function ignoresrm { ignores "$@" | xargs rm -f; }
159 function ignoresall { ignores -o -name "*.rej" "$@"; }
160 function ignoresallrm { ignoresall "$@" | xargs rm -f; }
161 function disass { objdump -D --target=binary --architecture=i386:x86-64 "$@"; }
162 function disass32 { objdump -D --target=binary --architecture=i386 "$@"; }
163 function cal {(unset cal; ( cal -m "$@"; ); );}
164 function vncreadonly { vncviewer -FullColor -Shared -ViewOnly "$@"; }
165 function diff {(unset diff; ( diff -dup "$@"; ); );}
166 $(: MAKEFLAGS= - "make install" does not expect -j and .spec files do not force -j1.)
167 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; }
168 function gdbn { gdb -nx --command=~/.gdbinit "$@"; }
169 function hd { od -Ax -tx1; }
170 function wget {(unset wget; ( wget --no-check-certificate "$@"; ); );}
171 function ucwkbd { setxkbmap -layout us,cz -variant ,ucw -option grp:caps_switch; }
172 function gdb {(unset gdb; ( gdb -q "$@"; ); );}
175 unset command_not_found_handle
176 shopt -u progcomp # Disable 'bash-completion' rpm
178 # '2>/dev/null' to prevent: TMOUT: readonly variable
179 [ -n "$SSH_TTY" ] && export TMOUT=900 2>/dev/null
181 #broken: [ -x /bin/less ] && export PAGER='/bin/less -rMMh5cis'
183 export PERL_LOCAL_LIB_ROOT="$HOME/perl5";
184 export PERL_MB_OPT="--install_base $HOME/perl5";
185 export PERL_MM_OPT="INSTALL_BASE=$HOME/perl5";
186 # Sometimes needed in non-interactive .bashrc.
187 # Unconditionally it would break quilt.
188 export PATH="$HOME/perl5/bin:$PATH";
190 for file in $HOME/.bookmarks.html;do
191 export WWW_HOME="file://$HOME/"
192 [ -r $file ] && export WWW_HOME="file://$file"
194 if echo x|grep --exclude=y -q x 2>/dev/null;then
195 alias grep='grep --exclude=tags --exclude=TAGS --exclude=ChangeLog* --exclude=*.svn-base --exclude=*~'
196 # FIXME: grep(1) ignores subdirectories for --exclude.
197 # --exclude=testsuite --exclude=.pc --exclude=.svn --exclude=CVS --exclude=po
199 if [ -n "$PS1" ];then # set only in interactive sessions
200 if [ ! -f /MOCK ];then
201 export PS1='[bash]${LOGNAME}@${HOSTNAME}:${PWD}# '
203 export PS1='[bash]${LOGNAME}@MOCK-'"`cat /MOCK`"':${PWD}# '
205 export PS1='\[\017\]'"$PS1" # \017=std charmap
206 if [ "${SHELL#*/com.termux/}" = "$SHELL" -a "${SSH_CLIENT#2a02:2b88:6:3b57::8f }" = "$SSH_CLIENT" ];then
207 export PS1='\[\033%G\]'"$PS1" # \033%G=utf-8
209 # Do not: kbd_mode -u # utf-8
210 # as it breaks keyboard state in X and it is not permitted for non-root.
212 export MINICOM="-m -c on" # metakeys+color
213 export HISTSIZE=10000000
214 export HISTFILESIZE="$HISTSIZE"
215 export GDBHISTFILE="$HOME/.gdb_history"
217 export TZ="Asia/Manila"
218 #export TZ="Europe/Prague"
219 #export TZ="Canada/Eastern"
220 export PYTHONUNBUFFERED=1
221 export ASAN_OPTIONS=detect_leaks=0
222 export GTK_OVERLAY_SCROLLING=0
224 export DEBUGINFOD_URLS=
225 cpus="`getconf _NPROCESSORS_ONLN`"
226 if [ -n "$cpus" ];then
227 # *3/2 was OOM for host1 32 CPUs + 16GB RAM
228 # *1 was OOM for host1 ccache -C;touch gui.h;time make all
229 # *3/4 was also OOM with KVM running
230 # *1/2 was OK for host1 32 CPUs + 16GB RAM
231 MAKEFLAGS="$MAKEFLAGS -j$[$cpus*1]"
234 if (which icecc && pidof iceccd) &>/dev/null;then
235 export CCACHE_PREFIX=icecc
237 # Do not: grep -w "$TERM" /etc/termcap >/dev/null || export TERM=vt220
238 # as Sun workaround as Debian misses: /etc/termcap
240 [ "$TERM" = vt220 -a "${uname_p%86}" != "$uname_p" ] && export TERM=linux
242 [ "$_selfabs" = "${_selfabs#/}" ] && _selfabs="$BASH_SOURCE"
243 [ "$_selfabs" = "${_selfabs#/}" ] && _selfabs="$PWD/.bashrc"
244 [ -r "$_selfabs" ] || unset _selfabs
245 [ -n "$_selfabs" ] && export VIMINIT="source `echo "$_selfabs"|sed 's/[.]bashrc$/.vimrc/'`"
248 unset LANG LANGUAGE `set|sed -n 's/^\(LC_[^=]*\)=.*$/\1/p'`
249 export LANG=en_US.UTF-8
250 # Force strcoll() to sort case-sensitively! (empty/undef doesn't work)
252 # Do not: # Prevent: perl: warning: Setting locale failed.
253 # # due to LC_COLLATE=C and LC_ALL=(unset)
255 # as it breaks Mutt "utf-8" and somehow it is no longer needed.
256 # Re: [Bug-readline] Readline 6.0 patch 004 trapped signal echoed to conso
257 # http://lists.gnu.org/archive/html/bug-readline/2009-09/msg00006.html
258 # 2>/dev/null for possible: stty: standard input: Inappropriate ioctl for device
259 stty -echoctl 2>/dev/null
260 export GIT_MERGE_AUTOEDIT=no
262 function wclines { awk '{x[$0]++}END{for (i in x) print x[i]"\t"i}'; }
263 # SunOS does not support "-m"
264 export ULIMITME_OPTS=""
265 for i in "-v 2000000";do
266 (ulimit $i 2>/dev/null) && ULIMITME_OPTS="$ULIMITME_OPTS $i"
268 if [ -z "$ULIMITME_OPTS" ];then
269 # MinGW64 would be printing "unlimited" on each ulimitme() execution.
270 ULIMITME_OPTS="-v unlimited"
272 # Prevent: ulimit: -m 100000 -d 150000 -v 200000: invalid number
273 # by forcing our known $IFS value; eval(1) is needed to take $IFS to effect:
274 function ulimitme { IFS=" " eval "ulimit 2>/dev/null $ULIMITME_OPTS"; }
275 function finame { find . -false `
276 awk </dev/null 'BEGIN{ for (i=1;i<ARGC;i++) print " -o -iname *"ARGV[i]"*"; }' "$@"
278 function mkcd { mkdir -p "$1"; cd "$1"; }
279 function pushdmk { mkdir -p "$1"; pushd "$1"; }
280 function rsync {(unset rsync; n rsync -c -a -v -e ssh --progress --stats --inplace --rsync-path='nice -n20 ionice -c3 rsync' "$@"; );}
281 function tohex { od -An -txC|tr -d '\n '|tr 'a-f' 'A-F';echo; }
283 find -type f|while read -r i;do
284 (awk </dev/null 'BEGIN{ for (i=1;i<ARGC;i++) print ARGV[i]; }' "$@";echo -e 'w\nq')|ed -s "$i"
288 set -ex;cd "$1";while true;do test "$PWD" != "/";if [ -e configure.in -o -e Makefile.PL ];then break;fi;cd ..;done;make install
290 function ctags {(unset ctags
291 if [ $# -ne 0 -a '(' $# -ne 1 -o "$1" '!=' "--c-types=+px" ')' ];then ctags "$@";else
292 find -name testsuite -prune -o -name gdbserver -prune -o -name .pc -prune -o -name .svn -prune -o \
293 -type f -a '!' -name tags -a '!' -name TAGS -a '(' -false \
294 -o -name "*.[chCy]" \
297 -o -name "*.[ch]pp" \
304 |ctags --extras=+f -L - --langmap=Tcl:+.exp "$@"
306 function ctagsh { ctags "--c-types=+px"; }
307 function cpan {(unset cpan; if [ $# = 0 ];then cpan;else perl -MCPAN -e "install qw($*);";fi; );}
308 function exx { cd "`unset exx;exx "$@"|tee /proc/self/fd/2|tail -n1|sed -n 's/^extdir=//p'`"; }
309 function debuginfo { if test -n "$*";then echo "$*";else cat;fi \
310 |xargs rpm -qf|xargs rpmquery --qf '%{SOURCERPM}\n'|sed 's/-[^-]*-[^-]*[.]src[.]rpm$/-debuginfo/'|sort -u; }
311 function ipcsrmall { ipcs|awk '/- Shared Memory/{x="-m"}/- Semaphore/{x="-s"}/^0x/{print "ipcrm "x" "$2}'; }
312 function eog {(unset eog; touch /tmp/eog.$$;eog "$@" {,,,,,,,,,}/tmp/eog.$$;rm -f /tmp/eog.$$; );}
313 function diffc { diff -dup "$@"|grep -v '^\(Only in \|Binary files\)'; }
314 function diffi { diffc -X ~/.diffi.list "$@" | diffdecvs; }
315 function cvs {(unset cvs
316 local _opts _opts_d _now _line _o
318 if grep -iw '\(sources.redhat.com\|sourceware.org\):/cvs/src' CVS/Root &>/dev/null;then _opts_d="";fi
319 if grep -iw '\(cvs.fedoraproject.org\):/cvs/pkgs' CVS/Root &>/dev/null;then _opts_d="";fi
320 if grep '^tests/kernel/syscalls/ptrace' CVS/Repository &>/dev/null;then _opts_d="";fi
328 if [ "$_o" = "--" ] && ! $_now;then _now=true;continue;fi
329 if [ "${_o#-}" != "$_o" ] && ! $_now;then continue;fi
330 if [ "$_o" = update -o "$_o" = upd -o "$_o" = up ];then _opts="$_opts_d";fi
333 cvs $_line $_opts "$@"
335 function perlrpm { repoquery -q --whatprovides $(for i in "$@";do echo "perl($i)";done|sed -e 's/\//::/g' -e 's/[.]pm//g'); }
336 # `-u' limits the search to $UID.
339 if [ "$1" = "-u" ];then
341 local r="$(pidof "$@")"
345 if grep -q "$(echo -e "^Uid:\t$UID\t")" "/proc/$p/status";then
355 function sumlog { find "$@" ! -name config.log -name "*.log" -o -name "*.sum"; }
356 function sourcewarecvscheckout {(set -ex
359 (set +x;cvs -z3 -d :pserver:anoncvs:@sourceware.org:/cvs/src checkout $1)
363 #(set +x;cvsignoresall)
366 function gdbgitclone { git clone git://sourceware.org/git/binutils-gdb.git gdb-git; }
367 function archergitclone { git clone git://sourceware.org/git/archer.git archer-git; }
368 function gdbcvscheckout { sourcewarecvscheckout gdb; }
369 function binutilscvscheckout { sourcewarecvscheckout binutils; }
370 function uri_escape { perl -MURI::Escape -le '$_=<>;chomp;print uri_escape $_;'; };
371 function uri_unescape { perl -MURI::Escape -le '$_=<>;chomp;print uri_unescape $_;'; };
372 alias fetchmail='n fetchmail'
373 function sleep_until { (set -x;sleep $[$(date -d "$*" +%s)-$(date +%s)]); }
377 echo >&2 "rpmsrclist gcc-4.3.2-7 [4.4.0-0.25 [-|http://kojipkgs.fedoraproject.org/packages/gcc/4.4.0/0.25/]]"
379 rpm -q --qf '%{SOURCERPM} %{name}-%{version}-%{release}.%{arch}\n' -a \
380 | grep "^$1.src.rpm " | sed 's/^[^ ]* //' \
382 if [ -z "$2" ]; then \
385 sed "s/-$(echo "$1"|sed 's/^.*-\([^-]*-[^-]*\)$/\1/')/-$2/"
388 if [ -z "$3" ]; then \
391 if [ "$3" != - ]; then
392 sed "s#.*#$3&.rpm#"; \
394 base="$(echo "$1"|sed 's/^\(.*\)-[^-]*-[^-]*$/\1/')"; \
395 sed "s#^.*-\([^-]*\)-\([^-]*\)\.\([^.]*\)\$#http://kojipkgs.fedoraproject.org/packages/$base/\1/\2/\3/&.rpm#"; \
401 function yumupdate {(ulimit -v unlimited;yum makecache;yum -y --skip-broken update "$@";);}
402 function gitcommit { git commit -a --allow-empty-message -m '' "$@"; }
403 function gpg {(unset gpg; http_proxy= all_proxy= HTTP_PROXY= ALL_PROXY= gpg "$@"; );}
404 function swap() {( set -ex;local TMPFILE=tmp.$$;[ $# = 2 ] && mv "$1" $TMPFILE && mv "$2" "$1" && mv $TMPFILE "$2" && echo done )}
405 alias gthumb='rm -rf ~/.cache/thumbnails/fail/;gthumb'
410 #RHEL6->7 breaks: echo spa\ ce ~/foo<tab>
415 if [ -f "$HOME/.bashrc.local" ];then source "$HOME/.bashrc.local";fi
418 for key in $HOME/.ssh/id_dsa;do
423 [ -r "$key" ] || continue
424 # Do not: [ -n "$SSH_TTY" ] && continue
425 # as we may want foreign SSH keys too.
427 agenteval=/tmp/.$USER.ssh-agent.eval
428 if lockfile -1 -r 3 -l 10 -s 1 $agenteval.lock;then
429 test -f $agenteval -a -O $agenteval -a -G $agenteval &&
430 # ">/dev/null" to prevent: echo Agent pid 31074
431 source $agenteval >/dev/null
432 if [ "ssh-agent" != "`(xargs -0 </proc/"$SSH_AGENT_PID"/cmdline sh -c 'echo "$0"') 2>/dev/null `" ];then
434 (test ! -e $agenteval && ssh-agent -s >$agenteval) || echo >&2 'Failing ssh-agent!'
435 # ">/dev/null" to prevent: echo Agent pid 31074
436 source $agenteval >/dev/null
438 rm -f $agenteval.lock
441 # Prevent gdm(8) lockups on non-interactive consoles.
443 (ssh-add -l|grep -qw "$key") && continue
444 if lockfile -! -1 -r 0 $agenteval.input.lock 2>/dev/null;then
445 echo >&2 -n "Locking: $agenteval.input.lock ... "
446 lockfile -1 -r -1 $agenteval.input.lock
449 # Recheck identity existence after the lock acquire
450 if ssh-add -l|grep -qw "$key";then
451 echo >&2 "Identity $key already appended in the meantime."
453 # "2>/dev/null" to prevent: Identity added: .ssh/id_dsa (.ssh/id_dsa)
454 ssh-add "$key" 2>/dev/null
456 rm -f $agenteval.input.lock
457 echo >&2 "$agenteval.input.lock unlocked."
461 unset _home_short_dotbashrc # permit later reinitializations
462 fi # _home_short_dotbashrc
464 true # Prevent crash in '-e' mode