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 if [ "$TZ" = Asia/Manila ];then
220 alias date='TZ=Asia/Manila date;TZ=Europe/Prague date'
222 export PYTHONUNBUFFERED=1
223 export ASAN_OPTIONS=detect_leaks=0
224 export GTK_OVERLAY_SCROLLING=0
226 export DEBUGINFOD_URLS=
227 cpus="`getconf _NPROCESSORS_ONLN`"
228 if [ -n "$cpus" ];then
229 # *3/2 was OOM for host1 32 CPUs + 16GB RAM
230 # *1 was OOM for host1 ccache -C;touch gui.h;time make all
231 # *3/4 was also OOM with KVM running
232 # *1/2 was OK for host1 32 CPUs + 16GB RAM
233 MAKEFLAGS="$MAKEFLAGS -j$[$cpus*1]"
236 if (which icecc && pidof iceccd) &>/dev/null;then
237 export CCACHE_PREFIX=icecc
239 # Do not: grep -w "$TERM" /etc/termcap >/dev/null || export TERM=vt220
240 # as Sun workaround as Debian misses: /etc/termcap
242 [ "$TERM" = vt220 -a "${uname_p%86}" != "$uname_p" ] && export TERM=linux
244 [ "$_selfabs" = "${_selfabs#/}" ] && _selfabs="$BASH_SOURCE"
245 [ "$_selfabs" = "${_selfabs#/}" ] && _selfabs="$PWD/.bashrc"
246 [ -r "$_selfabs" ] || unset _selfabs
247 [ -n "$_selfabs" ] && export VIMINIT="source `echo "$_selfabs"|sed 's/[.]bashrc$/.vimrc/'`"
250 unset LANG LANGUAGE `set|sed -n 's/^\(LC_[^=]*\)=.*$/\1/p'`
251 export LANG=en_US.UTF-8
252 # Force strcoll() to sort case-sensitively! (empty/undef doesn't work)
254 # Do not: # Prevent: perl: warning: Setting locale failed.
255 # # due to LC_COLLATE=C and LC_ALL=(unset)
257 # as it breaks Mutt "utf-8" and somehow it is no longer needed.
258 # Re: [Bug-readline] Readline 6.0 patch 004 trapped signal echoed to conso
259 # http://lists.gnu.org/archive/html/bug-readline/2009-09/msg00006.html
260 # 2>/dev/null for possible: stty: standard input: Inappropriate ioctl for device
261 stty -echoctl 2>/dev/null
262 export GIT_MERGE_AUTOEDIT=no
264 function wclines { awk '{x[$0]++}END{for (i in x) print x[i]"\t"i}'; }
265 # SunOS does not support "-m"
266 export ULIMITME_OPTS=""
267 for i in "-v 2000000";do
268 (ulimit $i 2>/dev/null) && ULIMITME_OPTS="$ULIMITME_OPTS $i"
270 if [ -z "$ULIMITME_OPTS" ];then
271 # MinGW64 would be printing "unlimited" on each ulimitme() execution.
272 ULIMITME_OPTS="-v unlimited"
274 # Prevent: ulimit: -m 100000 -d 150000 -v 200000: invalid number
275 # by forcing our known $IFS value; eval(1) is needed to take $IFS to effect:
276 function ulimitme { IFS=" " eval "ulimit 2>/dev/null $ULIMITME_OPTS"; }
277 function finame { find . -false `
278 awk </dev/null 'BEGIN{ for (i=1;i<ARGC;i++) print " -o -iname *"ARGV[i]"*"; }' "$@"
280 function mkcd { mkdir -p "$1"; cd "$1"; }
281 function pushdmk { mkdir -p "$1"; pushd "$1"; }
282 function rsync {(unset rsync; n rsync -c -a -v -e ssh --progress --stats --inplace --rsync-path='nice -n20 ionice -c3 rsync' "$@"; );}
283 function tohex { od -An -txC|tr -d '\n '|tr 'a-f' 'A-F';echo; }
285 find -type f|while read -r i;do
286 (awk </dev/null 'BEGIN{ for (i=1;i<ARGC;i++) print ARGV[i]; }' "$@";echo -e 'w\nq')|ed -s "$i"
290 set -ex;cd "$1";while true;do test "$PWD" != "/";if [ -e configure.in -o -e Makefile.PL ];then break;fi;cd ..;done;make install
292 function ctags {(unset ctags
293 if [ $# -ne 0 -a '(' $# -ne 1 -o "$1" '!=' "--c-types=+px" ')' ];then ctags "$@";else
294 find -name testsuite -prune -o -name gdbserver -prune -o -name .pc -prune -o -name .svn -prune -o \
295 -type f -a '!' -name tags -a '!' -name TAGS -a '(' -false \
296 -o -name "*.[chCy]" \
299 -o -name "*.[ch]pp" \
306 |ctags --extras=+f -L - --langmap=Tcl:+.exp "$@"
308 function ctagsh { ctags "--c-types=+px"; }
309 function cpan {(unset cpan; if [ $# = 0 ];then cpan;else perl -MCPAN -e "install qw($*);";fi; );}
310 function exx { cd "`unset exx;exx "$@"|tee /proc/self/fd/2|tail -n1|sed -n 's/^extdir=//p'`"; }
311 function debuginfo { if test -n "$*";then echo "$*";else cat;fi \
312 |xargs rpm -qf|xargs rpmquery --qf '%{SOURCERPM}\n'|sed 's/-[^-]*-[^-]*[.]src[.]rpm$/-debuginfo/'|sort -u; }
313 function ipcsrmall { ipcs|awk '/- Shared Memory/{x="-m"}/- Semaphore/{x="-s"}/^0x/{print "ipcrm "x" "$2}'; }
314 function eog {(unset eog; touch /tmp/eog.$$;eog "$@" {,,,,,,,,,}/tmp/eog.$$;rm -f /tmp/eog.$$; );}
315 function diffc { diff -dup "$@"|grep -v '^\(Only in \|Binary files\)'; }
316 function diffi { diffc -X ~/.diffi.list "$@" | diffdecvs; }
317 function cvs {(unset cvs
318 local _opts _opts_d _now _line _o
320 if grep -iw '\(sources.redhat.com\|sourceware.org\):/cvs/src' CVS/Root &>/dev/null;then _opts_d="";fi
321 if grep -iw '\(cvs.fedoraproject.org\):/cvs/pkgs' CVS/Root &>/dev/null;then _opts_d="";fi
322 if grep '^tests/kernel/syscalls/ptrace' CVS/Repository &>/dev/null;then _opts_d="";fi
330 if [ "$_o" = "--" ] && ! $_now;then _now=true;continue;fi
331 if [ "${_o#-}" != "$_o" ] && ! $_now;then continue;fi
332 if [ "$_o" = update -o "$_o" = upd -o "$_o" = up ];then _opts="$_opts_d";fi
335 cvs $_line $_opts "$@"
337 function perlrpm { repoquery -q --whatprovides $(for i in "$@";do echo "perl($i)";done|sed -e 's/\//::/g' -e 's/[.]pm//g'); }
338 # `-u' limits the search to $UID.
341 if [ "$1" = "-u" ];then
343 local r="$(pidof "$@")"
347 if grep -q "$(echo -e "^Uid:\t$UID\t")" "/proc/$p/status";then
357 function sumlog { find "$@" ! -name config.log -name "*.log" -o -name "*.sum"; }
358 function sourcewarecvscheckout {(set -ex
361 (set +x;cvs -z3 -d :pserver:anoncvs:@sourceware.org:/cvs/src checkout $1)
365 #(set +x;cvsignoresall)
368 function gdbgitclone { git clone git://sourceware.org/git/binutils-gdb.git gdb-git; }
369 function archergitclone { git clone git://sourceware.org/git/archer.git archer-git; }
370 function gdbcvscheckout { sourcewarecvscheckout gdb; }
371 function binutilscvscheckout { sourcewarecvscheckout binutils; }
372 function uri_escape { perl -MURI::Escape -le '$_=<>;chomp;print uri_escape $_;'; };
373 function uri_unescape { perl -MURI::Escape -le '$_=<>;chomp;print uri_unescape $_;'; };
374 alias fetchmail='n fetchmail'
375 function sleep_until { (set -x;sleep $[$(date -d "$*" +%s)-$(date +%s)]); }
379 echo >&2 "rpmsrclist gcc-4.3.2-7 [4.4.0-0.25 [-|http://kojipkgs.fedoraproject.org/packages/gcc/4.4.0/0.25/]]"
381 rpm -q --qf '%{SOURCERPM} %{name}-%{version}-%{release}.%{arch}\n' -a \
382 | grep "^$1.src.rpm " | sed 's/^[^ ]* //' \
384 if [ -z "$2" ]; then \
387 sed "s/-$(echo "$1"|sed 's/^.*-\([^-]*-[^-]*\)$/\1/')/-$2/"
390 if [ -z "$3" ]; then \
393 if [ "$3" != - ]; then
394 sed "s#.*#$3&.rpm#"; \
396 base="$(echo "$1"|sed 's/^\(.*\)-[^-]*-[^-]*$/\1/')"; \
397 sed "s#^.*-\([^-]*\)-\([^-]*\)\.\([^.]*\)\$#http://kojipkgs.fedoraproject.org/packages/$base/\1/\2/\3/&.rpm#"; \
403 function yumupdate {(ulimit -v unlimited;yum makecache;yum -y --skip-broken update "$@";);}
404 function gitcommit { git commit -a --allow-empty-message -m '' "$@"; }
405 function gpg {(unset gpg; http_proxy= all_proxy= HTTP_PROXY= ALL_PROXY= gpg "$@"; );}
406 function swap() {( set -ex;local TMPFILE=tmp.$$;[ $# = 2 ] && mv "$1" $TMPFILE && mv "$2" "$1" && mv $TMPFILE "$2" && echo done )}
407 alias gthumb='rm -rf ~/.cache/thumbnails/fail/;gthumb'
412 #RHEL6->7 breaks: echo spa\ ce ~/foo<tab>
417 if [ -f "$HOME/.bashrc.local" ];then source "$HOME/.bashrc.local";fi
420 for key in $HOME/.ssh/id_dsa;do
425 [ -r "$key" ] || continue
426 # Do not: [ -n "$SSH_TTY" ] && continue
427 # as we may want foreign SSH keys too.
429 agenteval=/tmp/.$USER.ssh-agent.eval
430 if lockfile -1 -r 3 -l 10 -s 1 $agenteval.lock;then
431 test -f $agenteval -a -O $agenteval -a -G $agenteval &&
432 # ">/dev/null" to prevent: echo Agent pid 31074
433 source $agenteval >/dev/null
434 if [ "ssh-agent" != "`(xargs -0 </proc/"$SSH_AGENT_PID"/cmdline sh -c 'echo "$0"') 2>/dev/null `" ];then
436 (test ! -e $agenteval && ssh-agent -s >$agenteval) || echo >&2 'Failing ssh-agent!'
437 # ">/dev/null" to prevent: echo Agent pid 31074
438 source $agenteval >/dev/null
440 rm -f $agenteval.lock
443 # Prevent gdm(8) lockups on non-interactive consoles.
445 (ssh-add -l|grep -qw "$key") && continue
446 if lockfile -! -1 -r 0 $agenteval.input.lock 2>/dev/null;then
447 echo >&2 -n "Locking: $agenteval.input.lock ... "
448 lockfile -1 -r -1 $agenteval.input.lock
451 # Recheck identity existence after the lock acquire
452 if ssh-add -l|grep -qw "$key";then
453 echo >&2 "Identity $key already appended in the meantime."
455 # "2>/dev/null" to prevent: Identity added: .ssh/id_dsa (.ssh/id_dsa)
456 ssh-add "$key" 2>/dev/null
458 rm -f $agenteval.input.lock
459 echo >&2 "$agenteval.input.lock unlocked."
463 unset _home_short_dotbashrc # permit later reinitializations
464 fi # _home_short_dotbashrc
466 true # Prevent crash in '-e' mode