diff --git a/src/bee-check.sh.in b/src/bee-check.sh.in index 2896c75..2fe0f7d 100644 --- a/src/bee-check.sh.in +++ b/src/bee-check.sh.in @@ -41,7 +41,7 @@ VERSION=${BEE_VERSION} ############################################################################### ## ## -pkg_check_all() { +function pkg_check_all() { if [ ! "${1}" ] ; then pkg_check @@ -57,7 +57,7 @@ pkg_check_all() { ############################################################################### ## ## -pkg_check_deps() { +function pkg_check_deps() { installed=$(${BEE_LIBEXECDIR}/bee/bee.d/bee-list --installed --by-pkgfullname ${1}) if [ ! "${installed}" -a $OPT_F -gt 0 ] ; then @@ -75,7 +75,7 @@ pkg_check_deps() { ############################################################################### ## ## -pkg_check() { +function pkg_check() { installed=$(${BEE_LIBEXECDIR}/bee/bee.d/bee-list --installed --by-pkgfullname ${1}) if [ ! "${installed}" -a $OPT_F -gt 0 ] ; then @@ -101,7 +101,7 @@ pkg_check() { } -do_check_deps_of_file() { +function do_check_deps_of_file() { local file=${1} local type="OTHER" @@ -175,7 +175,7 @@ do_check_deps_of_file() { ############################################################################### ## ## -do_check_deps() { +function do_check_deps() { local pkg=${1} local filesfile=${BEE_METADIR}/${pkg}/CONTENT @@ -222,7 +222,7 @@ do_check_deps() { ############################################################################### ## ## -do_check() { +function do_check() { local pkg=${1} local stat local full @@ -230,8 +230,8 @@ do_check() { echo "checking ${pkg} .." - for line in $(cat ${filesfile}) ; do - eval $(${BEESEP} ${line}) + while read line ; do + eval $(${BEESEP} "${line}") # save and strip possible symbolic link destination.. symlink=${file#*//} @@ -246,7 +246,7 @@ do_check() { if [ ! -h "${file}" ] ; then echo " [changed] ${file}" else - sdest=$(readlink ${file}) + sdest=$(readlink "${file}") if [ "${sdest}" != "${symlink}" ] ; then echo " [changed] ${file}" fi @@ -262,7 +262,7 @@ do_check() { fi else # regular file - check md5sum.. - md5now=$(md5sum ${file} | sed -e 's,^\([a-z0-9]*\).*$,\1,') + md5now=$(md5sum "${file}" | sed -e 's,^\([a-z0-9]*\).*$,\1,') if [ "${md5}" != "${md5now}" ] ; then echo " [changed] ${file}" @@ -271,7 +271,7 @@ do_check() { # check mode, uid and gid of directory/file - stat=( $(stat ${file} --printf "%f %u %g %U %G") ) + stat=( $(stat "${file}" --printf "%f %u %g %U %G") ) full=$(printf "0%o" 0x${stat[0]}) @@ -286,12 +286,12 @@ do_check() { if [ "${gid}" != "${stat[2]}" ] ; then echo " [changed] ${file}" fi - done + done < "${filesfile}" } ##### usage ################################################################### -usage() { +function usage() { cat <<-EOF bee-check v${VERSION} 2009-2012 by Marius Tolzmann and Tobias Dreyer <{tolzmann,dreyer}@molgen.mpg.de> diff --git a/src/bee-query.sh.in b/src/bee-query.sh.in index fbcec0f..1a9d2b5 100644 --- a/src/bee-query.sh.in +++ b/src/bee-query.sh.in @@ -46,7 +46,7 @@ usage() { EOF } -query() { +function query() { list=$@ for f in "${list[@]}" ; do @@ -57,36 +57,36 @@ query() { eval $(${BEE_BINDIR}/beeversion $base) get_files "${PKGALLPKG}" else - get_pkgs ${f} + get_pkgs "${f}" fi done } -get_files() { +function get_files() { pkg=${1} for s in "" "${BEE_METADIR}" ; do ff="${s}/${pkg}/CONTENT" if [ -e "${ff}" ] ; then - for line in $(cat ${ff}) ; do - eval $(${BEESEP} ${line}) + while read line ; do + eval $(${BEESEP} "${line}") echo ${file} - done + done < "${ff}" fi done } -get_pkgs() { +function get_pkgs() { f=$1 for pkg in $(${BEE_LIBEXECDIR}/bee/bee.d/bee-list --installed) ; do - if egrep -q "file=.*${f}" ${BEE_METADIR}/${pkg}/CONTENT ; then + if egrep -q "file=.*${f}" "${BEE_METADIR}/${pkg}/CONTENT" ; then echo ${pkg} - for line in $(egrep "file=.*${f}" ${BEE_METADIR}/${pkg}/CONTENT) ; do - eval $(${BEESEP} ${line}) + while read line ; do + eval $(${BEESEP} "${line}") echo " ${file}" - done + done < <(egrep "file=.*${f}" "${BEE_METADIR}/${pkg}/CONTENT") fi done } diff --git a/src/beecut.c b/src/beecut.c index d3553ef..a0358bc 100644 --- a/src/beecut.c +++ b/src/beecut.c @@ -159,6 +159,9 @@ int main(int argc, char *argv[]) case OPT_VERSION: print_version(); exit(EXIT_SUCCESS); + + case '?': + exit(EXIT_FAILURE); } } /* end while getopt_long_only */ diff --git a/src/beegetopt.c b/src/beegetopt.c index a66f5d3..ffbbd85 100644 --- a/src/beegetopt.c +++ b/src/beegetopt.c @@ -244,6 +244,8 @@ int main(int argc, char *argv[]) while((opt=bee_getopt(&optctl, &i)) != BEE_GETOPT_END) { if (opt == BEE_GETOPT_ERROR) { + free(beeopts); + free(beeoptptr); exit(1); }