]> git.pld-linux.org Git - packages/rpm.git/blobdiff - banner.sh
- reset/cleanup rpmdb only if the current backend is bdb, sqlite backend uses differe...
[packages/rpm.git] / banner.sh
old mode 100644 (file)
new mode 100755 (executable)
index c5ebd5c..e421556
--- a/banner.sh
+++ b/banner.sh
@@ -50,53 +50,43 @@ esac
 
 #################################################### FUNCTIONS ########
 
-Usage()
-{
+Usage() {
        cat << EOF
 Usage: $(basename $0) [options] [banners]
 EOF
 }
-Help()
-{
+
+Help() {
        Usage
        cat << EOF
--a
---all       - all banners
+-a, --all       - all banners
 -d, --delete    - delete specified banners
--e
---exclude   - exclude following banners (useful with -a)
--h
---help      - show this help
--i
---include   - cancel effect of -e (EXCLUDED banners will remain excluded)
--m
---make      - make a brand-new banner named as following parameter [1] (from stdin)
--M          - same as above, but append if file exists
--n
---names     - show names of the banners
---newer     - all choosen banners should be newer than following parameter in seconds
---older     - all choosen banners should be older than following parameter in seconds
--s
---show      - show specified banners
---stderr    - send banner to stderr instead of stdout (or other)
---stdout    - send banner to stdout instead of stderr (or other)
--u
---usage     - show short help
+-e, --exclude   - exclude following banners (useful with -a)
+-h, --help      - show this help
+-i, --include   - cancel effect of -e (EXCLUDED banners will remain excluded)
+-m, --make      - make a brand-new banner named as following parameter [1] (from stdin)
+-M              - same as above, but append if file exists
+-n, --names     - show names of the banners
+--newer         - all choosen banners should be newer than following parameter in seconds
+--older         - all choosen banners should be older than following parameter in seconds
+-s, --show      - show specified banners
+--stderr        - send banner to stderr instead of stdout (or other)
+--stdout        - send banner to stdout instead of stderr (or other)
+-u, --usage     - show short help
 
 [1] if there is no slash ('/') in the given name default dir ($BANNERDIR) is used,
     otherwise the one that's specified
 EOF
 }
-Unknown_para()
-{
+
+Unknown_para() {
        cat << EOF
 Unknown parameter $1
 EOF
        Help
 }
 
-check_banners_mtime()
-{
+check_banners_mtime() {
        BANNERS="$1"
        OLDER="$2"
        NEWER="$3"
@@ -112,34 +102,34 @@ check_banners_mtime()
                echo $BANNER
        done
 }
-delete_banners()
-{
+
+delete_banners() {
        BANNERS="$1"
        rm -rf $(get_banner_location_list "$BANNER")
 }
-get_all_banner_list()
-{
+
+get_all_banner_list() {
        ls "$BANNERDIR" | grep -E -v "$EXCLUDEFILES"
 }
-get_banner_list()
-{
+
+get_banner_list() {
        BANNERS="$1"
        NOBANNERS="$2"
        for BANNER in $BANNERS; do
-               if [ -r "$BANNERDIR/$BANNER" ];then
+               if [ -r "$BANNERDIR/$BANNER" ]; then
                        echo $NOBANNERS | grep -q $BANNER || echo $BANNER
                fi
        done
 }
-get_banner_location_list()
-{
+
+get_banner_location_list() {
        BANNERS="$1"
        for BANNER in $BANNERS; do
                echo "$BANNERDIR/$BANNER"
        done
 }
-make_banner()
-{
+
+make_banner() {
        BANNER="$1"
        SHOW="$2"
        if [ ! -d "${BANNER%/*}" ]; then
@@ -151,21 +141,22 @@ make_banner()
        else
                echo "$data" >> $BANNER
        fi
-       if [ $SHOW -eq 1 ];then
+       if [ $SHOW -eq 1 ]; then
                echo "$data"
        fi
 }
-show_banner()
-{
+
+show_banner() {
        cat "$BANNERDIR/$1" >&$STDOUT
 }
-show_banners()
-{
+
+show_banners() {
        for BANNER in $*; do
                show_banner $BANNER
        done
 }
-######################################################## MAIN ########
+
+######################################################### MAIN ########
 while [ -n "$1" ]; do
        case "$1" in
                -a|--all)
@@ -193,12 +184,12 @@ while [ -n "$1" ]; do
                                NEW_BANNER="$2"
                        fi
                        ACTION="make"
-                       if [ "$1" = "-M" ];then
+                       if [ "$1" = "-M" ]; then
                                NEW_APPEND=1
                        else
                                NEW_APPEND=0
                        fi
-                       if [ -z "$NEW_BANNER" ];then
+                       if [ -z "$NEW_BANNER" ]; then
                                Help
                                exit 2
                        fi
@@ -211,7 +202,7 @@ while [ -n "$1" ]; do
                --newer)
                        NEED_MTIME_CHECK=1
                        CHOOSE_NEWER="$2"
-                       if [ -z "$CHOOSE_NEWER" ];then
+                       if [ -z "$CHOOSE_NEWER" ]; then
                                Help
                                exit 2
                        fi
@@ -220,7 +211,7 @@ while [ -n "$1" ]; do
                --older)
                        NEED_MTIME_CHECK=1
                        CHOOSE_OLDER="$2"
-                       if [ -z "$CHOOSE_OLDER" ];then
+                       if [ -z "$CHOOSE_OLDER" ]; then
                                Help
                                exit 2
                        fi
@@ -246,7 +237,7 @@ while [ -n "$1" ]; do
                        exit 1
                        ;;
                *)
-                       if [ $EXCLUDE_FLAG -eq 0 ];then
+                       if [ $EXCLUDE_FLAG -eq 0 ]; then
                                BANNERS="$BANNERS ${1##*/}"
                        else
                                NOBANNERS="$NOBANNERS ${1##*/}"
@@ -259,30 +250,27 @@ done
 if [ $ALL_BANNERS -ne 0 ]; then
        BANNERS=`get_all_banner_list`
 fi
-if [ $NEED_BANNER_LIST -ne 0 ];then
+if [ $NEED_BANNER_LIST -ne 0 ]; then
        BANNER_LIST=`get_banner_list "$BANNERS" "$NOBANNERS"`
 fi
-if [ $NEED_MTIME_CHECK -ne 0 ];then
+if [ $NEED_MTIME_CHECK -ne 0 ]; then
        BANNER_LIST=`check_banners_mtime "$BANNER_LIST" "$CHOOSE_OLDER" "$CHOOSE_NEWER"`
 fi
 
 case $ACTION in
        "delete")
-               delete_banners $BANNER_LIST;
+               delete_banners $BANNER_LIST
                ;;
        "make")
-               make_banner $NEW_BANNER $NEW_SHOW;
+               make_banner $NEW_BANNER $NEW_SHOW
                ;;
        "names")
-               echo $BANNER_LIST;
+               echo $BANNER_LIST
                ;;
        "show")
-               show_banners $BANNER_LIST;
+               show_banners $BANNER_LIST
                ;;
        "")
                Help
                ;;
 esac
-
-
-
This page took 0.036324 seconds and 4 git commands to generate.