#!/bin/bash ### Imports ################################################################### source ScriptFunctions Import OptionParser ### Options ################################################################### scriptDescription="List files from a program in a 'clean' way, skipping some file patterns." scriptCredits="Copyright (C) 2006. Released under the GNU GPL." helpOnNoArguments=yes scriptUsage=" [] | " Add_Option_Boolean "f" "files" "List files (equivalent to -xtype f in 'find')" Add_Option_Boolean "l" "links" "List links (equivalent to -type l in 'find')" Add_Option_Boolean "p" "path" "Return full path, including the programs directory" Add_Option_Boolean "n" "null" "Separate files with null instead of newline." Parse_Options "$@" program="$(Arg 1)" version="$(Arg 2)" if [ -d "${program}" -a -n "$(echo "${program}" | grep '\/')" ] then [ "${program:0:1}" != "/" ] && Die "If called with a directory as an argument it must be an absolute path." programpath="${program}" # the first expressions strips any slash from end of path and second removes everything up to program name. program="$(echo "${programpath}" | sed -e 's,\(.*\)/$,\1,' -e 's,.*/\(.*/.*\),\1,' -e 's,\(.*\)/\(.*\),\1,')" version="$(echo "${programpath}" | sed -e 's,\(.*\)/$,\1,' -e 's,.*/\(.*/.*\),\1,' -e 's,\(.*\)/\(.*\),\2,')" else program=`GuessProgramCase "${program}"` if [ -z "${version}" ] then version=$(readlink -f "$goboPrograms/$program/Current") [ ! -d "$version" ] && Die "Current not found and no version specified." version=$(basename "$version") fi programpath="$goboPrograms/$program/$version" fi unset type if Boolean "files" && Boolean "links" then type="( -type f -or -type l )" elif Boolean "files" then type="-xtype f" elif Boolean "links" then type="-type l" fi if Boolean "path" then cd "${programpath%/$program/$version}" programpath="$program/$version/" else cd "${programpath}" programpath="*" fi Boolean "null" && printcommand="-print0" || printcommand="-print" find ${programpath} \( -path "CVS" \ -or -path "*/CVS" \ -or -path ".svn" \ -or -path "*/.svn" \ -or -path "${programpath}Resources/SettingsBackup*" \) -prune -or ${type} ${printcommand}