changeset 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
files bash
diffstat 1 files changed, 16 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/bash	Wed Apr 27 11:50:03 2011 -0400
+++ b/bash	Thu Apr 28 09:42:37 2011 +0700
@@ -4,14 +4,19 @@
 
 PATH="${HOME}/.ecos_bin:${HOME}/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
 
-PS1='[\u@\h \W]\$ '
+PS1="[\u@\h \W]\$ "
 
-export PAGER='less -Rins'
+export PAGER="less -Rins"
 export EDITOR=vi
 
-alias less='less -Rins'
+alias less="less -Rins"
+#assuming POSIX grep
+alias fgrep="grep -F"
+alias egrep="grep -E"
+
 _has_rm_I=
 _has_gnu_ls=
+_has_gnu_grep=
 _has_bsd_ls=
 case "$(uname -s)" in
   Linux)
@@ -21,12 +26,15 @@
   SunOS)
     [ -x /usr/gnu/bin/rm ] && _has_rm_I=y
     [ -x /usr/gnu/bin/ls ] && _has_gnu_ls=y
+    [ -x /usr/gnu/bin/grep ] && _has_gnu_grep=y
+    [ -d /usr/xpg4/bin ] && PATH="/usr/xpg4/bin:${PATH}"
     [ -d /opt/csw/bin ] && PATH="/opt/csw/bin:${PATH}"
     [ -d /opt/csw/sbin ] && PATH="/opt/csw/sbin:${PATH}"
     [ -d /usr/gnu/bin ] && PATH="/usr/gnu/bin:${PATH}"
   ;;
-  *BSD)
+  FreeBSD)
     _has_rm_I=y
+    CLICOLOR=
   ;;
 esac
 if [ "${_has_rm_I}" = y ]; then
@@ -41,6 +49,10 @@
   alias ls="ls -F"
 fi
 
+if [ "${_has_gnu_grep}" = y ]; then
+  alias grep="grep --color=auto"
+fi
+
 unset _has_rm_I
 unset _has_gnu_ls
 unset _has_bsd_ls