Commit 63b81646 authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm: fix call ourself when used with other name

parent c18c7c68
#!/bin/sh
#
# Copyright (C) 2012-2014 Etersoft
# Copyright (C) 2012-2014 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012-2016 Etersoft
# Copyright (C) 2012-2016 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
......@@ -17,10 +17,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
PROGDIR=$(dirname $0)
PROGDIR=$(dirname "$0")
PROGNAME=$(basename "$0")
[ "$PROGDIR" = "." ] && PROGDIR=$(pwd)
if [ "$0" = "/dev/stdin" ] || [ "$0" = "sh" ] ; then
PROGDIR=""
PROGNAME=""
fi
# will replaced to /usr/share/eepm during install
......@@ -89,9 +91,7 @@ pkg_names=
pkg_urls=
quoted_args=
progname="${0##*/}"
case $progname in
case $PROGNAME in
epmi)
epm_cmd=install
;;
......@@ -136,12 +136,17 @@ case $progname in
;;
epm|upm|eepm)
;;
epm.sh)
;;
*)
# epm by default
# fatal "Unknown command: $progname"
;;
esac
# was called with alias name
[ -n "$epm_cmd" ] && PROGNAME="epm"
check_command()
{
# do not override command
......@@ -397,7 +402,7 @@ pkg_filenames=$(strip_spaces "$pkg_files $pkg_names")
if [ -z "$epm_cmd" ] ; then
print_version
echo
fatal "Run $ $progname --help for get help"
fatal "Run $ $PROGNAME --help for get help"
fi
# Use eatmydata for write specific operations
......
......@@ -208,7 +208,8 @@ clean_store_output()
# run epm, possible from side repo
epm()
{
$PROGDIR/epm $@
[ -n "$PROGNAME" ] || fatal "Can't use epm call from the piped script"
$PROGDIR/$PROGNAME $@
}
# Print error message and stop the program
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment