User: ben
Date: 05/12/19 03:57:09
Modified: xemacs-builds/ben bash-functions
Log:
use grep -P if possible, grep -E otherwise; rearrange order of some funs
Revision Changes Path
1.3 +51 -35 XEmacs/xemacs-builds/ben/bash-functions
Index: bash-functions
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs-builds/ben/bash-functions,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -p -r1.2 -r1.3
--- bash-functions 2005/10/14 00:53:42 1.2
+++ bash-functions 2005/12/19 02:57:08 1.3
@@ -99,6 +99,17 @@ function dorec()
find . | xargs "$@"
}
+# $1 is a variable representing a directory, $2 its value
+# This sets $1 to $2 and makes $1 a command that cd's to the value of $1
+function make-dir-alias()
+{
+ eval "$1=\"$2\""
+ # no need to clutter up things with lots of aliases under zsh --
+ # auto_cd + cdable_vars + auto_name_dirs does the equivalent, but
+ # better (also handles pd/pop, etc.)
+ [ -n "$ZSH_NAME" ] || eval "alias $1='cd
\"\$$1\"'"
+}
+
# This generates text that can be pasted to easily generate functions
# such as rg(), below.
function makefind()
@@ -110,6 +121,8 @@ temacs.bsc
*.elc
*.exe
*.obj
+*.class
+*.pyc
TAGS
temacs.pdb
*.a
@@ -123,6 +136,13 @@ EOF
##### Grepping
+# see if grep -P is supported
+if echo foo | grep -P foo > /dev/null 2>&1 ; then
+ grepopt="-P"
+else
+ grepopt="-E"
+fi
+
# Recursive grep, excluding annoying files.
function rg()
{
@@ -134,6 +154,8 @@ function rg()
-name "*.elc" -o \
-name "*.exe" -o \
-name "*.obj" -o \
+ -name "*.class" -o \
+ -name "*.pyc" -o \
-name "TAGS" -o \
-name "*.pdb" -o \
-name "*.a" -o \
@@ -143,7 +165,7 @@ function rg()
-name "image.0*" -o \
-name "*.xpm" -o \
-name ".\#*" -o \
- -type f -print0 | xargs -0 grep -P "$@" | more
+ -type f -print0 | xargs -0 grep $grepopt "$@" | more
}
# Print out non-binary files
@@ -156,6 +178,8 @@ function printtext()
-name "*.elc" -o \
-name "*.exe" -o \
-name "*.obj" -o \
+ -name "*.class" -o \
+ -name "*.pyc" -o \
-name "*.pdb" -o \
-name "*.a" -o \
-name "*.dll" -o \
@@ -187,6 +211,8 @@ function nrg()
-name "*.elc" -o \
-name "*.exe" -o \
-name "*.obj" -o \
+ -name "*.class" -o \
+ -name "*.pyc" -o \
-name "TAGS" -o \
-name "*.pdb" -o \
-name "*.a" -o \
@@ -196,26 +222,26 @@ function nrg()
-name "image.0*" -o \
-name "*.xpm" -o \
-name ".\#*" -o \
- -type f -print0 | xargs -0 grep -P "$@" | more
+ -type f -print0 | xargs -0 grep $grepopt "$@" | more
}
# For use in XEmacs src directory. Grep all important files. For me
# (under Cygwin), this is much faster than `rg'.
function gx()
{
- egrep "$@" *.[chCH] s/*.[hH] m/*.[hH] *.in.in *.h.in | more
+ grep $grepopt "$@" *.[chCH] s/*.[hH] m/*.[hH] *.in.in *.h.in | more
}
# Grep .c and .h files in the current directory.
function gc()
{
- egrep "$@" *.[chCH] | more
+ grep $grepopt "$@" *.[chCH] | more
}
# Grep .h files in the current directory.
function gh()
{
- egrep "$@" *.[hH] | more
+ grep $grepopt "$@" *.[hH] | more
}
##### Global Search/Replace
@@ -460,7 +486,7 @@ function nmgrep()
{
for x in * ; do
echo $x;
- nm $x | egrep "$@"
+ nm $x | grep $grepopt "$@"
done
}
@@ -539,17 +565,6 @@ for y in $conf_all_config_names ; do
eval "dir$y=`config_options $y | sed 's/ /-/'g`"
done
-# $1 is a variable representing a directory, $2 its value
-# This sets $1 to $2 and makes $1 a command that cd's to the value of $1
-function make-dir-alias()
-{
- eval "$1=\"$2\""
- # no need to clutter up things with lots of aliases under zsh --
- # auto_cd + cdable_vars + auto_name_dirs does the equivalent, but
- # better (also handles pd/pop, etc.)
- [ -n "$ZSH_NAME" ] || eval "alias $1='cd
\"\$$1\"'"
-}
-
function make-ws-aliases()
{
make-dir-alias x$1 "$x/$2"
@@ -639,6 +654,25 @@ function xps2()
fi
}
+
+# basic function to build a package workspace from scratch. arguments are
+# workspace name.
+function bup()
+{
+ ws="$1"
+ shift
+ build --packages --keep-going $ws scratch "$@"
+}
+
+# basic function to rebuild an existing package workspace. arguments are
+# workspace name and configuration(s).
+function rebup()
+{
+ ws="$1"
+ shift
+ build --packages --keep-going $ws rebuild "$@"
+}
+
# Basic function to build a workspace from scratch. Arguments are
# workspace name and configuration(s).
function bu()
@@ -673,24 +707,6 @@ function rebunf()
ws="$1"
shift
build --keep-going --no-filter $ws rebuild "$@"
-}
-
-# basic function to build a package workspace from scratch. arguments are
-# workspace name.
-function bup()
-{
- ws="$1"
- shift
- build --packages --keep-going $ws scratch "$@"
-}
-
-# basic function to rebuild an existing package workspace. arguments are
-# workspace name and configuration(s).
-function rebup()
-{
- ws="$1"
- shift
- build --packages --keep-going $ws rebuild "$@"
}
# basic function to build a workspace from scratch for workspaces
Show replies by date