Author: adgor                        Date: Mon Oct  2 09:18:35 2006 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- Fixes suggested by glen - TX
  - Use awk instead of grep, cut, head etc.
  - Parse last (not first) definition (if multiple are)

---- Files affected:
SOURCES:
   fileutils.sh (1.6 -> 1.7) , fileutils.csh (1.4 -> 1.5) 

---- Diffs:

================================================================
Index: SOURCES/fileutils.sh
diff -u SOURCES/fileutils.sh:1.6 SOURCES/fileutils.sh:1.7
--- SOURCES/fileutils.sh:1.6    Mon Oct  2 02:14:08 2006
+++ SOURCES/fileutils.sh        Mon Oct  2 11:18:30 2006
@@ -2,9 +2,9 @@
 USER_RC_FILE=$HOME/.dir_colors
 DEF_COLOR_MODE=tty
 
-COLOR_MODE=`grep ^COLOR $SYS_RC_FILE |head -n 1|cut -c 7-`
+COLOR_MODE=`awk '/^COLOR/{c=$2} END{print c}' $SYS_RC_FILE`
 
-[ -r $USER_RC_FILE ] && COLOR_MODE=`grep ^COLOR $USER_RC_FILE |head -n 1|cut 
-c 7-`
+[ -r $USER_RC_FILE ] && COLOR_MODE=`awk '/^COLOR/{c=$2} END{print c}' 
$USER_RC_FILE`
 
 # 'all' argument for 'ls --color=' is no longer valid
 [ "$COLOR_MODE" = all ] && COLOR_MODE=always

================================================================
Index: SOURCES/fileutils.csh
diff -u SOURCES/fileutils.csh:1.4 SOURCES/fileutils.csh:1.5
--- SOURCES/fileutils.csh:1.4   Mon Oct  2 02:34:14 2006
+++ SOURCES/fileutils.csh       Mon Oct  2 11:18:30 2006
@@ -2,11 +2,11 @@
 set USER_RC_FILE=$HOME/.dir_colors
 set DEF_COLOR_MODE=tty
 
-set COLOR_MODE=`grep ^COLOR $SYS_RC_FILE |head -n 1|cut -c 7-`
+set COLOR_MODE=`awk '/^COLOR/{c=$2} END{print c}' $SYS_RC_FILE`
 
 test -r $USER_RC_FILE
 if ($status == 0) then
-       set COLOR_MODE=`grep ^COLOR $USER_RC_FILE |head -n 1|cut -c 7-`
+       set COLOR_MODE=`awk '/^COLOR/{c=$2} END{print c}' $USER_RC_FILE`
 endif
 
 # 'all' argument for 'ls --color=' is no longer valid
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/fileutils.sh?r1=1.6&r2=1.7&f=u
    http://cvs.pld-linux.org/SOURCES/fileutils.csh?r1=1.4&r2=1.5&f=u

_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to