#! /bin/bash # Last edited on 2012-12-08 21:31:06 by stolfilocal PROG_NAME=${0##*/} PROG_DESC="makes lists of source-like files under current directory, for grep etc." PROG_HELP=( "${PROG_NAME} [ -notheses ]" ) PROG_INFO=( "\nNAME" "\n ${PROG_NAME} - ${PROG_DESC}." "\n" "\nSYNOPSIS" "\n ${PROG_HELP[@]}" "\n" "\nDESCRIPTION" "\n Finds all source-like files under the current directory," "\n and creates the following files in it:" "\n" "\n .all-sources all source-like files (see find-all-sources)" "\n .chfiles all files called \"*.c\" and \"*.h\"" "\n .scripts all shallscript-like files (see find-all-scripts)" "\n .makefiles all makefile-like files (see find-all-makefiles)" "\n" "\nOPTIONS" "\n -notheses" "\n Excludes subdirectories called \"theses\", too, in any" "\n capitalization." "\n" "\nSEE ALSO" "\n find-all-sources(1)" "\nAUTHOR" "\n Created 2008-01-12 by Jorge Stolfi, Unicamp" ) # ---------------------------------------------------------------------- # INTERNAL OPTIONS # ---------------------------------------------------------------------- # COMMAND LINE PARSING # Parse command line switches: findops=() # bogus=( cat ) while [[ ( $# -ge 1 ) && ( "/$1" =~ /-.* ) ]]; do if [[ ( $# -ge 1 ) && ( "/$1" == "/-notheses" ) ]]; then findops=( "${findops[@]}" "$1" ); shift; # elif [[ ( $# -ge 2 ) && ( "/$1" == "/-bogus" ) ]]; then # extrop=( ${extrop[@]} "-bogus" "$2" ); shift; shift; else echo "unknown option $1" 1>&2 ; echo -e "usage:\n ${PROG_HELP[@]}" 1>&2 ; exit 1 fi done # echo "notheses = ( ${notheses[*]} )" 1>&2 find-all-sources "${findops[@]}" ./ \ | sed -e 's: [.]/: :g' \ > .all-sources cat .all-sources \ | egrep -e '[.][ch]$' \ > .chfiles find-all-scripts "${findops[@]}" ./ \ | sed -e 's: [.]/: :g' \ > .scripts find-all-makefiles "${findops[@]}" ./ \ | sed -e 's: [.]/: :g' \ > .makefiles echo "done." 1>&2