12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #!/bin/ksh
- #
- # GSRC = Grep SouRCe
- #
- # Grep files, but only those in a project define by a TM5 rc file.
- #
- # ARGUMENT : Regular Expression and options for Egrep
- # --------
- #
- # OPTION
- # ------
- #
- # -r RCFILE : rc file (default is $RCFILE in settings, if defined, or the
- # most recent)
- #
- #
- # SETTING : specify your TM5 dir and default rc file in the SETTINGS
- # --------- section
- #
- #
- # EXAMPLES
- # ---------
- #
- # gsrc -in "module dep"
- #
- #
- # LIMITATIONS
- # -----------
- # Works only with pycasso rcfiles.
- # A bit slow for repetitive search. See README in this dir for faster ways.
- #
- # 3 Jan 2011 - P. Le Sager - v0
- #
- ########################################################
- USAGE="\
- Grep SouRCe : look for PATTERN in TM5 source dirs.
-
- usage: ${0##*/} PATTERN
- "
- #----------------
- # SETTINGS
- #----------------
- # TM5 dir
- TM=$HOME/TM5MP
- # default RC file
- rcfile='base/trunk/rc/pycasso-tm5_chembase.rc'
- cd $TM
- # -----------------------------------------
- # Arguments
- # -----------------------------------------
- while getopts :r: OPT; do
- case $OPT in
- r) rcfile=$OPTARG
- ;;
- *) print "$USAGE"
- exit 2
- esac
- done
- shift $(( OPTIND - 1 ))
- # At least one argument
- [ $# -eq 0 ] && print "$USAGE" && exit 1
- # Use the most recent rc file if default does not exist
- [[ -f $rcfile ]] || rcfile=$(ls -1trL *.rc | tail -1)
- # list of files
- file=$(${0%/*}/get_tmflist -d $TM "$rcfile")
- egrep "$@" $file
- exit
|