comparison bash @ 53:b9db5d89aae3

[bash] POSIX grep, GNU grep, standardized quote (" unless ' required).
author Edho Prima Arief <me@myconan.net>
date Thu, 28 Apr 2011 09:42:37 +0700
parents d07ce874a280
children fd518e13cf4d
comparison
equal deleted inserted replaced
52:d07ce874a280 53:b9db5d89aae3
2 2
3 [ -f .ecos_bash.before ] && . .ecos_bash.before 3 [ -f .ecos_bash.before ] && . .ecos_bash.before
4 4
5 PATH="${HOME}/.ecos_bin:${HOME}/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin" 5 PATH="${HOME}/.ecos_bin:${HOME}/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
6 6
7 PS1='[\u@\h \W]\$ ' 7 PS1="[\u@\h \W]\$ "
8 8
9 export PAGER='less -Rins' 9 export PAGER="less -Rins"
10 export EDITOR=vi 10 export EDITOR=vi
11 11
12 alias less='less -Rins' 12 alias less="less -Rins"
13 #assuming POSIX grep
14 alias fgrep="grep -F"
15 alias egrep="grep -E"
16
13 _has_rm_I= 17 _has_rm_I=
14 _has_gnu_ls= 18 _has_gnu_ls=
19 _has_gnu_grep=
15 _has_bsd_ls= 20 _has_bsd_ls=
16 case "$(uname -s)" in 21 case "$(uname -s)" in
17 Linux) 22 Linux)
18 _has_rm_I=y 23 _has_rm_I=y
19 _has_gnu_ls=y 24 _has_gnu_ls=y
20 ;; 25 ;;
21 SunOS) 26 SunOS)
22 [ -x /usr/gnu/bin/rm ] && _has_rm_I=y 27 [ -x /usr/gnu/bin/rm ] && _has_rm_I=y
23 [ -x /usr/gnu/bin/ls ] && _has_gnu_ls=y 28 [ -x /usr/gnu/bin/ls ] && _has_gnu_ls=y
29 [ -x /usr/gnu/bin/grep ] && _has_gnu_grep=y
30 [ -d /usr/xpg4/bin ] && PATH="/usr/xpg4/bin:${PATH}"
24 [ -d /opt/csw/bin ] && PATH="/opt/csw/bin:${PATH}" 31 [ -d /opt/csw/bin ] && PATH="/opt/csw/bin:${PATH}"
25 [ -d /opt/csw/sbin ] && PATH="/opt/csw/sbin:${PATH}" 32 [ -d /opt/csw/sbin ] && PATH="/opt/csw/sbin:${PATH}"
26 [ -d /usr/gnu/bin ] && PATH="/usr/gnu/bin:${PATH}" 33 [ -d /usr/gnu/bin ] && PATH="/usr/gnu/bin:${PATH}"
27 ;; 34 ;;
28 *BSD) 35 FreeBSD)
29 _has_rm_I=y 36 _has_rm_I=y
37 CLICOLOR=
30 ;; 38 ;;
31 esac 39 esac
32 if [ "${_has_rm_I}" = y ]; then 40 if [ "${_has_rm_I}" = y ]; then
33 alias rm="rm -I" 41 alias rm="rm -I"
34 else 42 else
39 alias ls="ls -F --color=auto" 47 alias ls="ls -F --color=auto"
40 else 48 else
41 alias ls="ls -F" 49 alias ls="ls -F"
42 fi 50 fi
43 51
52 if [ "${_has_gnu_grep}" = y ]; then
53 alias grep="grep --color=auto"
54 fi
55
44 unset _has_rm_I 56 unset _has_rm_I
45 unset _has_gnu_ls 57 unset _has_gnu_ls
46 unset _has_bsd_ls 58 unset _has_bsd_ls
47 59
48 export PATH 60 export PATH