From: Antonio Ospite Date: Thu, 28 Jan 2010 21:03:39 +0000 (+0100) Subject: Check arguments in functions X-Git-Url: https://git.ao2.it/etcdiff.git/commitdiff_plain/92d43d71368540ea7b7d72d309d69a9133943638?ds=inline Check arguments in functions --- diff --git a/etcdiff.include b/etcdiff.include index e26498c..44564d8 100644 --- a/etcdiff.include +++ b/etcdiff.include @@ -3,6 +3,13 @@ _get_unpack_package() { PACKAGE=$1 + + if [ "x$PACKAGE" = "x" ]; + then + echo "Argument missing." + exit 1 + fi + FILEPATH=$(apt-cache show $PACKAGE | grep ^Filename | cut -d ' ' -f 2-) if [ "x$FILEPATH" = "x" ]; @@ -23,6 +30,12 @@ _do_etcdiff() ETCBASEDIR=$1 PREFIX=$2 + if [ "x$ETCBASEDIR" = "x" ]; + then + echo "Argument missing." + exit 1 + fi + REPORT_NAME=$(basename $ETCBASEDIR) # Report diff between debian conf and our local one @@ -73,6 +86,12 @@ etcdiff_by_package() { PACKAGE=$1 + if [ "x$PACKAGE" = "x" ]; + then + echo "Argument missing." + exit 1 + fi + if dpkg --status $PACKAGE | grep -q 'not-installed'; then echo "Package '$PACKAGE' not installed" @@ -97,6 +116,12 @@ etcdiff_by_file() { FILE=$1 + if [ "x$FILE" = "x" ]; + then + echo "Argument missing." + exit 1 + fi + if [ ! -e $FILE ]; then echo "ERROR, file $FILE does not exist."