Created
March 7, 2012 23:02
-
-
Save OndraZizka/1996990 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function usage { | |
echo | |
echo " Usage: testsuite/tools/showSrc.sh <part-of-file-name>" | |
echo | |
} | |
## Determine this script's location ("Tools" home dir). | |
scriptPath="$(cd "${0%/*}" 2>/dev/null; echo "$PWD"/"${0##*/}")" | |
# For the case when called through a symlink | |
scriptPath=`readlink -f "$scriptPath"` | |
scriptDir=`dirname $scriptPath` | |
############# | |
if [ "$1" = "" ] ; then usage; exit 1; fi | |
## Pick an IDE. | |
EDITOR=${EDITOR:-vi} | |
if [ "$IDE" = "" ] && which netbeans &>/dev/null; then IDE=netbeans; fi | |
if [ "$IDE" = "" ] && which eclipse &>/dev/null; then IDE=eclipse; fi | |
if [ "$IDE" = "" ]; then | |
echo " No \$IDE set, using \$EDITOR - $EDITOR." | |
IDE=$EDITOR; | |
fi | |
## Path restriction. | |
if [ "$2" != "" ] ; then PATH_MASK="-path \\*$2\\*"; | |
else PATH_MASK="-path 'testsuite/*'"; | |
fi | |
set -x | |
FIND="find $scriptDir/../.. -name '*$1*.java' -or -name '*$1*.xml' $PATH_MASK"; | |
echo $FIND; | |
## Prevent killing the IDE with hundreds of files. | |
NUM=$( $FIND | wc -l ) | |
echo $NUM | |
if [[ $NUM -ge 30 ]] ; then | |
echo " ERROR: More than 30 files found, not passing to the IDE to prevent overload."; | |
$FIND | head -60 | |
echo "..." | |
exit 2; | |
fi | |
SOURCES=`$FIND` | |
if [ "" == "$SOURCES" ] ; then | |
echo "No sources found."; | |
exit 0; | |
fi; | |
echo " Opening $NUM files with $IDE." | |
$IDE $SOURCES; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ondra@lenovo:~/work/AS7/ozizka-git$ testsuite/tools/showSrc.sh Cluster
find /home/ondra/work/AS7/ozizka-git/testsuite/tools/../.. -name 'Cluster.java' -or -name 'Cluster.xml' -path 'testsuite/'
++ wc -l
++ find /home/ondra/work/AS7/ozizka-git/testsuite/tools/../.. -name ''''Cluster.java'''' -or -name ''''Cluster.xml'''' -path ''''testsuite/*''''
0
++ find /home/ondra/work/AS7/ozizka-git/testsuite/tools/../.. -name ''''Cluster.java'''' -or -name ''''Cluster.xml'''' -path ''''testsuite/*''''
No sources found.