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

epm: fix call ourself when used with other name

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