#!/bin/bash

##############################################################################
#                                                                            #
#  Title    : foo                                                            #
#  Author   : gapz                                                           #
#  E-Mail   : gapz at distronux.org                                          #
#  Web site : http://gapz.tuxfamily.org                                      #
#                                                                            #
##############################################################################
#                                                                            #
#  This program is free software; you can redistribute it and/or modify      #
#  it under the terms of the GNU General Public License as published by      #
#  the Free Software Foundation; either version 2 of the License, or         #
#  (at your option) any later version.                                       #
#                                                                            #
#  This program is distributed in the hope that it will be useful,           #
#  but WITHOUT ANY WARRANTY; without even the implied warranty of            #
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             #
#  GNU General Public License for more details.                              #
#                                                                            #
#  You should have received a copy of the GNU General Public License         #
#  along with this program; if not, write to the Free Software               #
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA #
#                                                                            #
##############################################################################

check_success()

{
  if [ "$?" == "0" ]; then
    echo -e " success\007" # Makes a beep when successful. - Raphael
  else
    echo -e " failed"
  fi
}

if [ "$1" ]; then

    case "$1" in

        *.tar.gz|*.tgz|*.tar.Z|*..tar.z)
            tar cfvz $@
            check_success
            ;;

        *.tar.bz2|*.tbz2)
            tar cjvf $@
            check_success
            ;;

        --help*|-help*)
            echo "
            Usage: foo [archive_name]. : tar.gz/tar.bz2 [file_to_archive]
            "
            ;;
        *)
            echo "file type unknow"
            ;;
    esac

else

    echo "
    Usage: foo [archive_name]. : tar.gz/tar.bz2 [file_to_archive]
    "

fi