Commit a73ad379 authored by Vitaly Lipatov's avatar Vitaly Lipatov

make shellcheck happy

parent 50fa87aa
...@@ -33,7 +33,7 @@ rpmvendor() ...@@ -33,7 +33,7 @@ rpmvendor()
[ "$DISTRIB_ID" = "LinuxXP" ] && echo "lxp" && return [ "$DISTRIB_ID" = "LinuxXP" ] && echo "lxp" && return
[ "$DISTRIB_ID" = "TinyCoreLinux" ] && echo "tcl" && return [ "$DISTRIB_ID" = "TinyCoreLinux" ] && echo "tcl" && return
[ "$DISTRIB_ID" = "VoidLinux" ] && echo "void" && return [ "$DISTRIB_ID" = "VoidLinux" ] && echo "void" && return
echo "$DISTRIB_ID" | tr "A-Z" "a-z" echo "$DISTRIB_ID" | tr "[:lower:]"
} }
# Translate DISTRIB_ID name to package manner (like in the package release name) # Translate DISTRIB_ID name to package manner (like in the package release name)
...@@ -46,7 +46,7 @@ pkgvendor() ...@@ -46,7 +46,7 @@ pkgvendor()
# Print pkgtype (need DISTRIB_ID var) # Print pkgtype (need DISTRIB_ID var)
pkgtype() pkgtype()
{ {
case `pkgvendor` in case $(pkgvendor) in
freebsd) echo "tbz" ;; freebsd) echo "tbz" ;;
sunos) echo "pkg.gz" ;; sunos) echo "pkg.gz" ;;
slackware|mopslinux) echo "tgz" ;; slackware|mopslinux) echo "tgz" ;;
...@@ -86,9 +86,9 @@ DISTRIB_CODENAME="" ...@@ -86,9 +86,9 @@ DISTRIB_CODENAME=""
# Default with LSB # Default with LSB
if distro lsb-release ; then if distro lsb-release ; then
DISTRIB_ID=`cat $DISTROFILE | get_var DISTRIB_ID` DISTRIB_ID=$(cat $DISTROFILE | get_var DISTRIB_ID)
DISTRIB_RELEASE=`cat $DISTROFILE | get_var DISTRIB_RELEASE` DISTRIB_RELEASE=$(cat $DISTROFILE | get_var DISTRIB_RELEASE)
DISTRIB_CODENAME=`cat $DISTROFILE | get_var DISTRIB_CODENAME` DISTRIB_CODENAME=$(cat $DISTROFILE | get_var DISTRIB_CODENAME)
fi fi
# ALT Linux based # ALT Linux based
...@@ -121,8 +121,8 @@ if distro altlinux-release ; then ...@@ -121,8 +121,8 @@ if distro altlinux-release ; then
elif distro gentoo-release ; then elif distro gentoo-release ; then
DISTRIB_ID="Gentoo" DISTRIB_ID="Gentoo"
MAKEPROFILE=$(readlink $ROOTDIR/etc/portage/make.profile 2>/dev/null) || MAKEPROFILE=$(readlink $ROOTDIR/etc/make.profile) MAKEPROFILE=$(readlink $ROOTDIR/etc/portage/make.profile 2>/dev/null) || MAKEPROFILE=$(readlink $ROOTDIR/etc/make.profile)
DISTRIB_RELEASE=`basename $MAKEPROFILE` DISTRIB_RELEASE=$(basename $MAKEPROFILE)
echo $DISTRIB_RELEASE | grep -q "[0-9]" || DISTRIB_RELEASE=`basename $(dirname $MAKEPROFILE)` echo $DISTRIB_RELEASE | grep -q "[0-9]" || DISTRIB_RELEASE=$(basename "$(dirname $MAKEPROFILE)")
# Slackware based # Slackware based
elif distro mopslinux-version ; then elif distro mopslinux-version ; then
...@@ -135,19 +135,22 @@ elif distro mopslinux-version ; then ...@@ -135,19 +135,22 @@ elif distro mopslinux-version ; then
fi fi
elif distro slackware-version ; then elif distro slackware-version ; then
DISTRIB_ID="Slackware" DISTRIB_ID="Slackware"
DISTRIB_RELEASE="$(grep -Eo [0-9]+\.[0-9]+ $DISTROFILE)" DISTRIB_RELEASE="$(grep -Eo '[0-9]+\.[0-9]+' $DISTROFILE)"
elif distro os-release && which apk 2>/dev/null >/dev/null ; then elif distro os-release && which apk 2>/dev/null >/dev/null ; then
# shellcheck disable=SC1090
. $ROOTDIR/etc/os-release . $ROOTDIR/etc/os-release
DISTRIB_ID="$ID" DISTRIB_ID="$ID"
DISTRIB_RELEASE="$VERSION_ID" DISTRIB_RELEASE="$VERSION_ID"
elif distro os-release && which tce-ab 2>/dev/null >/dev/null ; then elif distro os-release && which tce-ab 2>/dev/null >/dev/null ; then
# shellcheck disable=SC1090
. $ROOTDIR/etc/os-release . $ROOTDIR/etc/os-release
DISTRIB_ID="TinyCoreLinux" DISTRIB_ID="TinyCoreLinux"
DISTRIB_RELEASE="$VERSION_ID" DISTRIB_RELEASE="$VERSION_ID"
elif distro os-release && which xbps-query 2>/dev/null >/dev/null ; then elif distro os-release && which xbps-query 2>/dev/null >/dev/null ; then
# shellcheck disable=SC1090
. $ROOTDIR/etc/os-release . $ROOTDIR/etc/os-release
DISTRIB_ID="VoidLinux" DISTRIB_ID="VoidLinux"
DISTRIB_RELEASE="Live" DISTRIB_RELEASE="Live"
...@@ -270,32 +273,32 @@ elif distro SuSe-release || distro SuSE-release ; then ...@@ -270,32 +273,32 @@ elif distro SuSe-release || distro SuSE-release ; then
fi fi
# fixme: can we detect by some file? # fixme: can we detect by some file?
elif [ `uname` = "FreeBSD" ] ; then elif [ "$(uname)" = "FreeBSD" ] ; then
DISTRIB_ID="FreeBSD" DISTRIB_ID="FreeBSD"
UNAME=$(uname -r) UNAME=$(uname -r)
DISTRIB_RELEASE=$(echo "$UNAME" | grep RELEASE | sed -e "s|\([0-9]\.[0-9]\)-RELEASE|\1|g") DISTRIB_RELEASE=$(echo "$UNAME" | grep RELEASE | sed -e "s|\([0-9]\.[0-9]\)-RELEASE|\1|g")
# fixme: can we detect by some file? # fixme: can we detect by some file?
elif [ `uname` = "SunOS" ] ; then elif [ "$(uname)" = "SunOS" ] ; then
DISTRIB_ID="SunOS" DISTRIB_ID="SunOS"
DISTRIB_RELEASE=$(uname -r) DISTRIB_RELEASE=$(uname -r)
# fixme: can we detect by some file? # fixme: can we detect by some file?
elif [ `uname -s 2>/dev/null` = "Darwin" ] ; then elif [ "$(uname -s 2>/dev/null)" = "Darwin" ] ; then
DISTRIB_ID="MacOS" DISTRIB_ID="MacOS"
DISTRIB_RELEASE=$(uname -r) DISTRIB_RELEASE=$(uname -r)
# fixme: move to up # fixme: move to up
elif [ `uname` = "Linux" ] && which guix 2>/dev/null >/dev/null ; then elif [ "$(uname)" = "Linux" ] && which guix 2>/dev/null >/dev/null ; then
DISTRIB_ID="GNU/Linux/Guix" DISTRIB_ID="GNU/Linux/Guix"
DISTRIB_RELEASE=$(uname -r) DISTRIB_RELEASE=$(uname -r)
# fixme: move to up # fixme: move to up
elif [ `uname` = "Linux" ] && [ -x $ROOTDIR/system/bin/getprop ] ; then elif [ "$(uname)" = "Linux" ] && [ -x $ROOTDIR/system/bin/getprop ] ; then
DISTRIB_ID="Android" DISTRIB_ID="Android"
DISTRIB_RELEASE=$(getprop | awk -F": " '/build.version.release/ { print $2 }' | tr -d '[]') DISTRIB_RELEASE=$(getprop | awk -F": " '/build.version.release/ { print $2 }' | tr -d '[]')
elif [ `uname -o 2>/dev/null` = "Cygwin" ] ; then elif [ "$(uname -o 2>/dev/null)" = "Cygwin" ] ; then
DISTRIB_ID="Cygwin" DISTRIB_ID="Cygwin"
DISTRIB_RELEASE="all" DISTRIB_RELEASE="all"
......
...@@ -33,6 +33,7 @@ load_helper() ...@@ -33,6 +33,7 @@ load_helper()
local CMD="$SHAREDIR/$1" local CMD="$SHAREDIR/$1"
# do not use fatal() here, it can be initial state # do not use fatal() here, it can be initial state
[ -r "$CMD" ] || { echo "FATAL: Have no $CMD helper file" ; exit 1; } [ -r "$CMD" ] || { echo "FATAL: Have no $CMD helper file" ; exit 1; }
# shellcheck disable=SC1090
. $CMD . $CMD
} }
......
...@@ -46,7 +46,7 @@ case $DISTRNAME in ...@@ -46,7 +46,7 @@ case $DISTRNAME in
;; ;;
autoimports) autoimports)
[ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION" [ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION"
repo="$repo.$(echo "$DISTRVERSION" | tr "A-Z" "a-z")" repo="$repo.$(echo "$DISTRVERSION" | tr "[:upper:]" "[:lower:]")"
esac esac
assure_exists apt-repo assure_exists apt-repo
......
...@@ -28,7 +28,7 @@ __check_command_in_path() ...@@ -28,7 +28,7 @@ __check_command_in_path()
# Note: used egrep! write '[0-9]+(first|two)', not '[0-9]\+...' # Note: used egrep! write '[0-9]+(first|two)', not '[0-9]\+...'
rhas() rhas()
{ {
echo "$1" | egrep -q -- "$2" echo "$1" | grep -E -q -- "$2"
} }
# copied from strings # copied from strings
...@@ -122,5 +122,6 @@ epm_assure() ...@@ -122,5 +122,6 @@ epm_assure()
[ -n "$pkg_filenames" ] || fatal "Assure: Missing params. Check $0 --help for info." [ -n "$pkg_filenames" ] || fatal "Assure: Missing params. Check $0 --help for info."
# use helper func for extract separate params # use helper func for extract separate params
# shellcheck disable=SC2046
__epm_assure $(eval echo $quoted_args) __epm_assure $(eval echo $quoted_args)
} }
...@@ -118,6 +118,7 @@ case $PMTYPE in ...@@ -118,6 +118,7 @@ case $PMTYPE in
yum-rpm) yum-rpm)
# cleanup orphanes? # cleanup orphanes?
while true ; do while true ; do
# shellcheck disable=SC2046
docmd package-cleanup --leaves $(subst_option non_interactive --assumeyes) docmd package-cleanup --leaves $(subst_option non_interactive --assumeyes)
# FIXME: package-cleanup have to use stderr for errors # FIXME: package-cleanup have to use stderr for errors
local PKGLIST=$(package-cleanup -q --leaves | grep -v "^eepm-") local PKGLIST=$(package-cleanup -q --leaves | grep -v "^eepm-")
......
...@@ -58,11 +58,11 @@ update_repo_if_needed() ...@@ -58,11 +58,11 @@ update_repo_if_needed()
sudo -n true 2>/dev/null || { info "sudo requires a password, skip repo status checking" ; return 0 ; } sudo -n true 2>/dev/null || { info "sudo requires a password, skip repo status checking" ; return 0 ; }
fi fi
cd / cd / || fatal
if ! __is_repo_info_downloaded || ! __is_repo_info_uptodate ; then if ! __is_repo_info_downloaded || ! __is_repo_info_uptodate ; then
load_helper epm-update load_helper epm-update
pkg_filenames='' epm_update pkg_filenames='' epm_update
fi fi
cd - >/dev/null cd - >/dev/null || fatal
} }
...@@ -26,5 +26,5 @@ epm_epm_install(){ ...@@ -26,5 +26,5 @@ epm_epm_install(){
# FIXME: some way to get latest package # FIXME: some way to get latest package
local download_link=$etersoft_updates_site/$(wget -qO- $etersoft_updates_site/ | grep -m1 -Eo "eepm[^\"]+\.$($DISTRVENDOR -p)" | tail -n1) #" local download_link=$etersoft_updates_site/$(wget -qO- $etersoft_updates_site/ | grep -m1 -Eo "eepm[^\"]+\.$($DISTRVENDOR -p)" | tail -n1) #"
pkg_names= pkg_files= pkg_urls=$download_link epm_install pkg_names='' pkg_files='' pkg_urls="$download_link" epm_install
} }
...@@ -59,8 +59,11 @@ __epm_filelist_remote() ...@@ -59,8 +59,11 @@ __epm_filelist_remote()
;; ;;
apt-dpkg) apt-dpkg)
assure_exists apt-file || return assure_exists apt-file || return
# if sudo requires a password, skip autoupdate if sudo -n true 2>/dev/null ; then
sudo -n true 2>/dev/null && sudocmd apt-file update || info "sudo requires a password, skip apt-file update" sudocmd apt-file update
else
info "sudo requires a password, skip apt-file update"
fi
docmd_foreach __deb_local_content_filelist "$@" docmd_foreach __deb_local_content_filelist "$@"
;; ;;
yum-rpm) yum-rpm)
...@@ -164,6 +167,7 @@ epm_filelist() ...@@ -164,6 +167,7 @@ epm_filelist()
__epm_filelist_file $pkg_files || return __epm_filelist_file $pkg_files || return
# shellcheck disable=SC2046
__epm_filelist_name $(print_name $pkg_names) || return __epm_filelist_name $(print_name $pkg_names) || return
} }
...@@ -37,6 +37,7 @@ filter_out_installed_packages() ...@@ -37,6 +37,7 @@ filter_out_installed_packages()
# sed -e 's|\.\+$||g' -e 's|^.*[Nn]o packages found matching \(.*\)|\1|g' # sed -e 's|\.\+$||g' -e 's|^.*[Nn]o packages found matching \(.*\)|\1|g'
# ;; # ;;
*) *)
# shellcheck disable=SC2013
for i in $(cat) ; do for i in $(cat) ; do
is_installed $i || echo $i is_installed $i || echo $i
done done
...@@ -146,14 +147,14 @@ epm_install_names() ...@@ -146,14 +147,14 @@ epm_install_names()
return ;; return ;;
homebrew) homebrew)
# FIXME: sudo and quote # FIXME: sudo and quote
SUDO= __separate_sudocmd "brew install" "brew upgrade" $@ SUDO='' __separate_sudocmd "brew install" "brew upgrade" "$@"
return ;; return ;;
ipkg) ipkg)
[ -n "$force" ] && force=-force-depends [ -n "$force" ] && force=-force-depends
sudocmd ipkg $force install $@ sudocmd ipkg $force install $@
return ;; return ;;
nix) nix)
__separate_sudocmd "nix-env --install" "nix-env --upgrade" $@ __separate_sudocmd "nix-env --install" "nix-env --upgrade" "$@"
return ;; return ;;
apk) apk)
sudocmd apk add $@ sudocmd apk add $@
...@@ -221,7 +222,7 @@ epm_ni_install_names() ...@@ -221,7 +222,7 @@ epm_ni_install_names()
return ;; return ;;
npackd) npackd)
# npackdcl update --package=<package> (remove old and install new) # npackdcl update --package=<package> (remove old and install new)
sudocmd npackdcl add --package=$@ sudocmd npackdcl add --package="$*"
return ;; return ;;
chocolatey) chocolatey)
docmd chocolatey install $@ docmd chocolatey install $@
...@@ -243,7 +244,7 @@ epm_ni_install_names() ...@@ -243,7 +244,7 @@ epm_ni_install_names()
return ;; return ;;
homebrew) homebrew)
# FIXME: sudo and quote # FIXME: sudo and quote
SUDO= __separate_sudocmd "brew install" "brew upgrade" $@ SUDO='' __separate_sudocmd "brew install" "brew upgrade" $@
return ;; return ;;
#android) #android)
# sudocmd pm install $@ # sudocmd pm install $@
...@@ -279,7 +280,7 @@ __epm_check_if_try_install_deb() ...@@ -279,7 +280,7 @@ __epm_check_if_try_install_deb()
assure_exists alien assure_exists alien
local TDIR=$(mktemp -d) local TDIR=$(mktemp -d)
cd $TDIR cd $TDIR || fatal
for pkg in $debpkgs ; do for pkg in $debpkgs ; do
# TODO: fakeroot for non ALT? # TODO: fakeroot for non ALT?
showcmd_store_output alien -r -k --scripts "$pkg" || fatal showcmd_store_output alien -r -k --scripts "$pkg" || fatal
...@@ -309,7 +310,7 @@ __epm_check_if_try_install_rpm() ...@@ -309,7 +310,7 @@ __epm_check_if_try_install_rpm()
assure_exists fakeroot assure_exists fakeroot
local TDIR=$(mktemp -d) local TDIR=$(mktemp -d)
cd $TDIR cd $TDIR || fatal
for pkg in $rpmpkgs ; do for pkg in $rpmpkgs ; do
showcmd_store_output fakeroot alien -d -k --scripts "$pkg" showcmd_store_output fakeroot alien -d -k --scripts "$pkg"
local DEBCONVERTED=$(grep "deb generated" $RC_STDOUT | sed -e "s| generated||g") local DEBCONVERTED=$(grep "deb generated" $RC_STDOUT | sed -e "s| generated||g")
...@@ -472,48 +473,48 @@ epm_print_install_command() ...@@ -472,48 +473,48 @@ epm_print_install_command()
{ {
case $PMTYPE in case $PMTYPE in
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm|dnf-rpm) apt-rpm|yum-rpm|urpm-rpm|zypper-rpm|dnf-rpm)
echo "rpm -Uvh --force $nodeps $@" echo "rpm -Uvh --force $nodeps $*"
;; ;;
apt-dpkg|aptitude-dpkg) apt-dpkg|aptitude-dpkg)
echo "dpkg -i $@" echo "dpkg -i $*"
;; ;;
pkgsrc) pkgsrc)
echo "pkg_add $@" echo "pkg_add $*"
;; ;;
pkgng) pkgng)
echo "pkg add $@" echo "pkg add $*"
;; ;;
emerge) emerge)
# need be placed in /usr/portage/packages/somewhere # need be placed in /usr/portage/packages/somewhere
echo "emerge --usepkg $@" echo "emerge --usepkg $*"
;; ;;
pacman) pacman)
echo "pacman -U --noconfirm --force $nodeps $@" echo "pacman -U --noconfirm --force $nodeps $*"
;; ;;
slackpkg) slackpkg)
echo "/sbin/installpkg $@" echo "/sbin/installpkg $*"
;; ;;
npackd) npackd)
echo "npackdcl add --package=$@" echo "npackdcl add --package=$*"
;; ;;
ipkg) ipkg)
echo "ipkg install $@" echo "ipkg install $*"
;; ;;
android) android)
echo "pm install $@" echo "pm install $*"
;; ;;
aptcyg) aptcyg)
echo "apt-cyg install $@" echo "apt-cyg install $*"
;; ;;
tce) tce)
echo "tce-load -wi $@" echo "tce-load -wi $*"
;; ;;
xbps) xbps)
echo "xbps-install -y $@" echo "xbps-install -y $*"
;; ;;
homebrew) homebrew)
# FIXME: sudo and quote # FIXME: sudo and quote
echo "brew install $@" echo "brew install $*"
;; ;;
*) *)
......
...@@ -25,7 +25,7 @@ __repack_rpm_base() ...@@ -25,7 +25,7 @@ __repack_rpm_base()
cd /var/lib/rpm || fatal cd /var/lib/rpm || fatal
mv Packages Packages.BACKUP || fatal mv Packages Packages.BACKUP || fatal
# mask dependencies with a= # mask dependencies with a=
a='' db_dump Packages.BACKUP | a= db_load Packages || fatal a='' db_dump Packages.BACKUP | a='' db_load Packages || fatal
rm Packages.BACKUP rm Packages.BACKUP
} }
......
...@@ -33,7 +33,7 @@ epm_programs() ...@@ -33,7 +33,7 @@ epm_programs()
[ -d "$DESKTOPDIR" ] || fatal "There is no $DESKTOPDIR dir on the system." [ -d "$DESKTOPDIR" ] || fatal "There is no $DESKTOPDIR dir on the system."
#find /usr/share/applications -type f -name "*.desktop" | while read f; do pkg_files="$f" quiet=1 short=1 epm_query_file ; done | sort -u #find /usr/share/applications -type f -name "*.desktop" | while read f; do pkg_files="$f" quiet=1 short=1 epm_query_file ; done | sort -u
showcmd "find $DESKTOPDIR -type f -name "*.desktop" | xargs $0 -qf --quiet --short | sort -u" showcmd "find $DESKTOPDIR -type f -print0 -name "*.desktop" | xargs -0 $0 -qf --quiet --short | sort -u"
find $DESKTOPDIR -type f -name "*.desktop" | \ find $DESKTOPDIR -type f -print0 -name "*.desktop" | \
xargs $0 -qf --quiet --short | sort -u xargs -0 $0 -qf --quiet --short | sort -u
} }
...@@ -22,7 +22,7 @@ load_helper epm-print ...@@ -22,7 +22,7 @@ load_helper epm-print
epm_provides_files() epm_provides_files()
{ {
local pkg_files="$@" local pkg_files="$*"
[ -n "$pkg_files" ] || return [ -n "$pkg_files" ] || return
local PKGTYPE="$(get_package_type $pkg_files)" local PKGTYPE="$(get_package_type $pkg_files)"
...@@ -46,7 +46,7 @@ epm_provides_files() ...@@ -46,7 +46,7 @@ epm_provides_files()
epm_provides_names() epm_provides_names()
{ {
local pkg_names="$@" local pkg_names="$*"
local CMD local CMD
[ -n "$pkg_names" ] || return [ -n "$pkg_names" ] || return
...@@ -106,5 +106,6 @@ epm_provides() ...@@ -106,5 +106,6 @@ epm_provides()
[ -n "$pkg_filenames" ] || fatal "Provides: missing package(s) name" [ -n "$pkg_filenames" ] || fatal "Provides: missing package(s) name"
epm_provides_files $pkg_files epm_provides_files $pkg_files
# shellcheck disable=SC2046
epm_provides_names $(print_name $pkg_names) epm_provides_names $(print_name $pkg_names)
} }
...@@ -180,7 +180,7 @@ __epm_query_name() ...@@ -180,7 +180,7 @@ __epm_query_name()
return return
;; ;;
npackd) npackd)
docmd "npackdcl path --package=$@" docmd "npackdcl path --package=$1"
return return
;; ;;
conary) conary)
...@@ -226,7 +226,7 @@ __epm_query_shortname() ...@@ -226,7 +226,7 @@ __epm_query_shortname()
return return
;; ;;
npackd) npackd)
docmd "npackdcl path --package=$@" docmd "npackdcl path --package=$1"
return return
;; ;;
conary) conary)
...@@ -270,7 +270,7 @@ separate_installed() ...@@ -270,7 +270,7 @@ separate_installed()
{ {
pkg_installed= pkg_installed=
pkg_noninstalled= pkg_noninstalled=
for i in $* ; do for i in "$@" ; do
is_installed $i && pkg_installed="$pkg_installed $i" || pkg_noninstalled="$pkg_noninstalled $i" is_installed $i && pkg_installed="$pkg_installed $i" || pkg_noninstalled="$pkg_noninstalled $i"
done done
} }
...@@ -282,8 +282,10 @@ epm_query() ...@@ -282,8 +282,10 @@ epm_query()
__epm_query_file $pkg_files || return __epm_query_file $pkg_files || return
if [ -n "$short" ] ; then if [ -n "$short" ] ; then
# shellcheck disable=SC2046
__epm_query_shortname $(print_name $pkg_names) || return __epm_query_shortname $(print_name $pkg_names) || return
else else
# shellcheck disable=SC2046
__epm_query_name $(print_name $pkg_names) || return __epm_query_name $(print_name $pkg_names) || return
fi fi
} }
...@@ -63,7 +63,7 @@ __do_query_real_file() ...@@ -63,7 +63,7 @@ __do_query_real_file()
dpkg_print_name_version() dpkg_print_name_version()
{ {
local ver i local ver i
for i in $* ; do for i in "$@" ; do
ver=$(dpkg -s $i 2>/dev/null | grep "Version:" | sed -e "s|Version: ||g") ver=$(dpkg -s $i 2>/dev/null | grep "Version:" | sed -e "s|Version: ||g")
if [ -z "$ver" ] ; then if [ -z "$ver" ] ; then
echo "$i" echo "$i"
...@@ -82,8 +82,8 @@ __do_query() ...@@ -82,8 +82,8 @@ __do_query()
CMD="rpm -qf" CMD="rpm -qf"
;; ;;
*-dpkg) *-dpkg)
showcmd dpkg -S $1 showcmd dpkg -S "$1"
dpkg_print_name_version $(dpkg -S $1 | grep -v "^diversion by" | sed -e "s|:.*||") dpkg_print_name_version "$(dpkg -S $1 | grep -v "^diversion by" | sed -e "s|:.*||")"
return ;; return ;;
yum-rpm|dnf-rpm|urpm-rpm) yum-rpm|dnf-rpm|urpm-rpm)
CMD="rpm -qf" CMD="rpm -qf"
...@@ -138,8 +138,8 @@ __do_short_query() ...@@ -138,8 +138,8 @@ __do_short_query()
CMD="rpm -qf --queryformat %{NAME}\n" CMD="rpm -qf --queryformat %{NAME}\n"
;; ;;
NOapt-dpkg) NOapt-dpkg)
showcmd dpkg -S $1 showcmd dpkg -S "$1"
dpkg_print_name_version $(dpkg -S $1 | sed -e "s|:.*||" | grep -v "^diversion by") dpkg_print_name_version "$(dpkg -S $1 | sed -e "s|:.*||" | grep -v "^diversion by")"
return ;; return ;;
NOemerge) NOemerge)
assure_exists equery assure_exists equery
......
...@@ -22,7 +22,7 @@ load_helper epm-search ...@@ -22,7 +22,7 @@ load_helper epm-search
__epm_query_package() __epm_query_package()
{ {
pkg_filenames="$@" quoted_args="$@" quiet=1 epm_query_package pkg_filenames="$*" quoted_args="$*" quiet=1 epm_query_package
} }
epm_query_package() epm_query_package()
......
...@@ -40,7 +40,7 @@ __detect_alt_release_by_repo() ...@@ -40,7 +40,7 @@ __detect_alt_release_by_repo()
| grep "[tp][5-9]/branch/" \ | grep "[tp][5-9]/branch/" \
| sed -e "s|.*\([tp][5-9]\)/branch.*|\1|g" \ | sed -e "s|.*\([tp][5-9]\)/branch.*|\1|g" \
| sort -u ) | sort -u )
if [ $(__wcount $BRD) = "1" ] ; then if [ "$(__wcount $BRD)" = "1" ] ; then
echo "$BRD" echo "$BRD"
return return
fi fi
...@@ -50,7 +50,7 @@ __detect_alt_release_by_repo() ...@@ -50,7 +50,7 @@ __detect_alt_release_by_repo()
| grep "Sisyphus/" \ | grep "Sisyphus/" \
| sed -e "s|.*\(Sisyphus\).*|\1|g" \ | sed -e "s|.*\(Sisyphus\).*|\1|g" \
| sort -u ) | sort -u )
if [ $(__wcount $BRD) = "1" ] ; then if [ "$(__wcount $BRD)" = "1" ] ; then
echo "$BRD" echo "$BRD"
return return
fi fi
...@@ -63,9 +63,9 @@ __replace_alt_version_in_repo() ...@@ -63,9 +63,9 @@ __replace_alt_version_in_repo()
local i local i
assure_exists apt-repo assure_exists apt-repo
#echo "Upgrading $DISTRNAME from $1 to $2 ..." #echo "Upgrading $DISTRNAME from $1 to $2 ..."
docmd apt-repo list | sed -e "s|\($1\)|{\1}->{$2}|g" | egrep --color -- "$1" docmd apt-repo list | sed -e "s|\($1\)|{\1}->{$2}|g" | grep -E --color -- "$1"
# ask and replace only we will have changes # ask and replace only we will have changes
if a='' apt-repo list | egrep -q -- "$1" ; then if a='' apt-repo list | grep -E -q -- "$1" ; then
confirm "Are these correct changes? [y/N]" || fatal "Exiting" confirm "Are these correct changes? [y/N]" || fatal "Exiting"
__replace_text_in_alt_repo "/^ *#/! s!$1!$2!g" __replace_text_in_alt_repo "/^ *#/! s!$1!$2!g"
fi fi
...@@ -95,7 +95,7 @@ __update_to_the_distro() ...@@ -95,7 +95,7 @@ __update_to_the_distro()
case "$TO" in case "$TO" in
p7) p7)
docmd epm update || fatal docmd epm update || fatal
docmd epm install apt rpm apt-conf-branch $(get_fix_release_pkg $TO) || fatal "Check an error and run epm release-upgrade again" docmd epm install apt rpm apt-conf-branch "$(get_fix_release_pkg "$TO")" || fatal "Check an error and run epm release-upgrade again"
__alt_repofix __alt_repofix
__replace_text_in_alt_repo "/^ *#/! s!\[updates\]![$TO]!g" __replace_text_in_alt_repo "/^ *#/! s!\[updates\]![$TO]!g"
docmd epm update || fatal docmd epm update || fatal
...@@ -103,10 +103,10 @@ __update_to_the_distro() ...@@ -103,10 +103,10 @@ __update_to_the_distro()
;; ;;
p8) p8)
docmd epm update || fatal docmd epm update || fatal
if ! docmd epm install apt rpm apt-conf-branch $(get_fix_release_pkg $TO) ; then if ! docmd epm install apt rpm apt-conf-branch "$(get_fix_release_pkg "$TO")" ; then
# Hack for error: execution of %post scriptlet from glibc-core-2.23-alt1.eter1 # Hack for error: execution of %post scriptlet from glibc-core-2.23-alt1.eter1
docmd rpm -ev glibc-core-2.17 || fatal "Check an error and run epm release-upgrade again" docmd rpm -ev glibc-core-2.17 || fatal "Check an error and run epm release-upgrade again"
docmd epm install apt rpm apt-conf-branch $(get_fix_release_pkg $TO) || fatal "Check an error and run epm release-upgrade again" docmd epm install apt rpm apt-conf-branch "$(get_fix_release_pkg "$TO")" || fatal "Check an error and run epm release-upgrade again"
fi fi
__alt_repofix __alt_repofix
__replace_text_in_alt_repo "/^ *#/! s!\[updates\]![$TO]!g" __replace_text_in_alt_repo "/^ *#/! s!\[updates\]![$TO]!g"
...@@ -144,7 +144,7 @@ __update_alt_to_next_distro() ...@@ -144,7 +144,7 @@ __update_alt_to_next_distro()
"p7"|"p7 p8"|"t7 p8") "p7"|"p7 p8"|"t7 p8")
TO="p8" TO="p8"
info "Upgrade $DISTRNAME from $FROM to $TO ..." info "Upgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install apt-conf-branch $(get_fix_release_pkg $FROM) || fatal docmd epm install apt-conf-branch "$(get_fix_release_pkg "$FROM")" || fatal
__replace_alt_version_in_repo $FROM/branch/ $TO/branch/ __replace_alt_version_in_repo $FROM/branch/ $TO/branch/
__update_to_the_distro $TO __update_to_the_distro $TO
docmd epm update-kernel || fatal docmd epm update-kernel || fatal
......
...@@ -29,6 +29,7 @@ epm_remove_low() ...@@ -29,6 +29,7 @@ epm_remove_low()
sudocmd rpm -ev $nodeps $@ sudocmd rpm -ev $nodeps $@
return ;; return ;;
apt-dpkg|aptitude-dpkg) apt-dpkg|aptitude-dpkg)
# shellcheck disable=SC2046
sudocmd dpkg -P $(subst_option nodeps --force-all) $(print_name "$@") sudocmd dpkg -P $(subst_option nodeps --force-all) $(print_name "$@")
return ;; return ;;
pkgsrc) pkgsrc)
...@@ -102,7 +103,7 @@ epm_remove_names() ...@@ -102,7 +103,7 @@ epm_remove_names()
sudocmd conary erase $@ sudocmd conary erase $@
return ;; return ;;
npackd) npackd)
sudocmd npackdcl remove --package=$@ sudocmd npackdcl remove --package=$1
return ;; return ;;
nix) nix)
sudocmd nix-env --uninstall $@ sudocmd nix-env --uninstall $@
...@@ -132,6 +133,7 @@ epm_remove_names() ...@@ -132,6 +133,7 @@ epm_remove_names()
sudocmd xbps remove -R $@ sudocmd xbps remove -R $@
return ;; return ;;
ipkg) ipkg)
# shellcheck disable=SC2046
sudocmd ipkg $(subst_option force -force-depends) remove $@ sudocmd ipkg $(subst_option force -force-depends) remove $@
return ;; return ;;
*) *)
...@@ -185,34 +187,34 @@ epm_print_remove_command() ...@@ -185,34 +187,34 @@ epm_print_remove_command()
{ {
case $PMTYPE in case $PMTYPE in
apt-rpm|yum-rpm|zypper-rpm|urpm-rpm|dnf-rpm) apt-rpm|yum-rpm|zypper-rpm|urpm-rpm|dnf-rpm)
echo "rpm -ev $nodeps $@" echo "rpm -ev $nodeps $*"
;; ;;
apt-dpkg|aptitude-dpkg) apt-dpkg|aptitude-dpkg)
echo "dpkg -P $@" echo "dpkg -P $*"
;; ;;
pkgsrc) pkgsrc)
echo "pkg_delete -r $@" echo "pkg_delete -r $*"
;; ;;
pkgng) pkgng)
echo "pkg delete -R $@" echo "pkg delete -R $*"
;; ;;
pacman) pacman)
echo "pacman -R $@" echo "pacman -R $*"
;; ;;
emerge) emerge)
echo "emerge --unmerge $@" echo "emerge --unmerge $*"
;; ;;
slackpkg) slackpkg)
echo "/sbin/removepkg $@" echo "/sbin/removepkg $*"
;; ;;
ipkg) ipkg)
echo "ipkg remove $@" echo "ipkg remove $*"
;; ;;
aptcyg) aptcyg)
echo "apt-cyg remove $@" echo "apt-cyg remove $*"
;; ;;
xbps) xbps)
echo "xbps remove -y $@" echo "xbps remove -y $*"
;; ;;
*) *)
fatal "Have no suitable appropriate remove command for $PMTYPE" fatal "Have no suitable appropriate remove command for $PMTYPE"
......
...@@ -27,7 +27,7 @@ case $DISTRNAME in ...@@ -27,7 +27,7 @@ case $DISTRNAME in
autoimports) autoimports)
info "remove autoimports repo" info "remove autoimports repo"
[ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION" [ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION"
repo="$repo.$(echo "$DISTRVERSION" | tr "A-Z" "a-z")" repo="$repo.$(echo "$DISTRVERSION" | tr "[:upper:]" "[:lower:]")"
;; ;;
esac esac
......
...@@ -22,7 +22,7 @@ load_helper epm-print ...@@ -22,7 +22,7 @@ load_helper epm-print
epm_requires_files() epm_requires_files()
{ {
local pkg_files="$@" local pkg_files="$*"
[ -n "$pkg_files" ] || return [ -n "$pkg_files" ] || return
local PKGTYPE="$(get_package_type $pkg_files)" local PKGTYPE="$(get_package_type $pkg_files)"
...@@ -128,5 +128,6 @@ epm_requires() ...@@ -128,5 +128,6 @@ epm_requires()
{ {
[ -n "$pkg_filenames" ] || fatal "Requires: missing package(s) name" [ -n "$pkg_filenames" ] || fatal "Requires: missing package(s) name"
epm_requires_files $pkg_files epm_requires_files $pkg_files
# shellcheck disable=SC2046
epm_requires_names $(print_name $pkg_names) epm_requires_names $(print_name $pkg_names)
} }
...@@ -90,7 +90,7 @@ case $PMTYPE in ...@@ -90,7 +90,7 @@ case $PMTYPE in
CMD="xbps-query -Ro" CMD="xbps-query -Ro"
;; ;;
aptcyg) aptcyg)
docmd apt-cyg searchall $(echo " $pkg_filenames" | sed -e "s| /| |g") docmd apt-cyg searchall "$(echo " $pkg_filenames" | sed -e "s| /| |g")"
return return
;; ;;
*) *)
......
...@@ -38,7 +38,7 @@ get_local_alt_mirror_path() ...@@ -38,7 +38,7 @@ get_local_alt_mirror_path()
__local_ercat() __local_ercat()
{ {
local i local i
for i in $* ; do for i in "$@" ; do
case "$i" in case "$i" in
*.xz) *.xz)
a='' xzcat $i a='' xzcat $i
...@@ -106,7 +106,7 @@ get_local_alt_contents_index() ...@@ -106,7 +106,7 @@ get_local_alt_contents_index()
local LOCALPATH local LOCALPATH
epm_repolist | grep -E "rpm.*(ftp://|http://|https://|file:/)" | sed -e "s@^rpm.*\(ftp://\|http://\|https://\|file:\)@\1@g" | while read URL ARCH other ; do epm_repolist | grep -E "rpm.*(ftp://|http://|https://|file:/)" | sed -e "s@^rpm.*\(ftp://\|http://\|https://\|file:\)@\1@g" | while read -r URL ARCH other ; do
LOCALPATH=$(get_local_alt_mirror_path "$URL/$ARCH") LOCALPATH=$(get_local_alt_mirror_path "$URL/$ARCH")
download_alt_contents_index $URL/$ARCH/base/contents_index $LOCALPATH >&2 || continue download_alt_contents_index $URL/$ARCH/base/contents_index $LOCALPATH >&2 || continue
echo "$LOCALPATH/contents_index*" echo "$LOCALPATH/contents_index*"
......
...@@ -48,7 +48,7 @@ check_tty() ...@@ -48,7 +48,7 @@ check_tty()
# egrep from busybox may not --color # egrep from busybox may not --color
# egrep from MacOS print help to stderr # egrep from MacOS print help to stderr
if egrep --help 2>&1 | grep -q -- "--color" ; then if grep -E --help 2>&1 | grep -q -- "--color" ; then
export EGREPCOLOR="--color" export EGREPCOLOR="--color"
fi fi
...@@ -89,7 +89,7 @@ echover() ...@@ -89,7 +89,7 @@ echover()
echon() echon()
{ {
# default /bin/sh on MacOS does not recognize -n # default /bin/sh on MacOS does not recognize -n
/bin/echo -n "$@" /bin/echo -n "$*"
} }
...@@ -109,7 +109,7 @@ showcmd() ...@@ -109,7 +109,7 @@ showcmd()
set_boldcolor $GREEN set_boldcolor $GREEN
local PROMTSIG="\$" local PROMTSIG="\$"
[ "$EFFUID" = 0 ] && PROMTSIG="#" [ "$EFFUID" = 0 ] && PROMTSIG="#"
echo " $PROMTSIG $@" echo " $PROMTSIG $*"
restore_color restore_color
fi >&2 fi >&2
} }
...@@ -117,7 +117,7 @@ showcmd() ...@@ -117,7 +117,7 @@ showcmd()
# Print command line and run command line # Print command line and run command line
docmd() docmd()
{ {
showcmd "$@$EXTRA_SHOWDOCMD" showcmd "$*$EXTRA_SHOWDOCMD"
#FIXME #FIXME
$@ $@
} }
...@@ -137,7 +137,7 @@ docmd_foreach() ...@@ -137,7 +137,7 @@ docmd_foreach()
# Print command line and run command line with SUDO # Print command line and run command line with SUDO
sudocmd() sudocmd()
{ {
showcmd "$SUDO $@" showcmd "$SUDO $*"
$SUDO $@ $SUDO $@
} }
...@@ -170,11 +170,10 @@ get_firstarg() ...@@ -170,11 +170,10 @@ get_firstarg()
get_lastarg() get_lastarg()
{ {
local lastarg local lastarg
eval lastarg=\${$#} eval "lastarg=\${$#}"
echon "$lastarg" echon "$lastarg"
} }
filter_strip_spaces() filter_strip_spaces()
{ {
# possible use just # possible use just
...@@ -202,7 +201,7 @@ store_output() ...@@ -202,7 +201,7 @@ store_output()
echo 1 >$CMDSTATUS echo 1 >$CMDSTATUS
#RC_STDERR=$(mktemp) #RC_STDERR=$(mktemp)
( $@ 2>&1 ; echo $? >$CMDSTATUS ) | tee $RC_STDOUT ( $@ 2>&1 ; echo $? >$CMDSTATUS ) | tee $RC_STDOUT
return $(cat $CMDSTATUS) return "$(cat $CMDSTATUS)"
# bashism # bashism
# http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF # http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF
#return $PIPESTATUS #return $PIPESTATUS
...@@ -230,7 +229,7 @@ epm() ...@@ -230,7 +229,7 @@ epm()
fatal() fatal()
{ {
if [ -z "$TEXTDOMAIN" ] ; then if [ -z "$TEXTDOMAIN" ] ; then
echo "Error: $@" >&2 echo "Error: $*" >&2
# else # else
# echog "Error in $0: $@" >&2 # echog "Error in $0: $@" >&2
fi fi
...@@ -241,7 +240,7 @@ fatal() ...@@ -241,7 +240,7 @@ fatal()
warning() warning()
{ {
if [ -z "$TEXTDOMAIN" ] ; then if [ -z "$TEXTDOMAIN" ] ; then
echo "Warning: $@" >&2 echo "Warning: $*" >&2
# else # else
# echog "Error in $0: $@" >&2 # echog "Error in $0: $@" >&2
fi fi
...@@ -254,9 +253,9 @@ info() ...@@ -254,9 +253,9 @@ info()
# print message to stderr if stderr forwarded to (a file) # print message to stderr if stderr forwarded to (a file)
if isatty2 ; then if isatty2 ; then
isatty || return 0 isatty || return 0
echo "$@" echo "$*"
else else
echo "$@" >&2 echo "$*" >&2
fi fi
} }
...@@ -270,7 +269,7 @@ set_sudo() ...@@ -270,7 +269,7 @@ set_sudo()
return return
fi fi
EFFUID=`id -u` EFFUID=$(id -u)
# do not need sudo # do not need sudo
[ $EFFUID = "0" ] && return [ $EFFUID = "0" ] && return
...@@ -414,7 +413,7 @@ get_help() ...@@ -414,7 +413,7 @@ get_help()
return return
fi fi
grep -v -- "^#" $0 | grep -- "# $1" | while read n ; do grep -v -- "^#" $0 | grep -- "# $1" | while read -r n ; do
opt=$(echo $n | sed -e "s|) # $1:.*||g") opt=$(echo $n | sed -e "s|) # $1:.*||g")
desc=$(echo $n | sed -e "s|.*) # $1:||g") desc=$(echo $n | sed -e "s|.*) # $1:||g")
printf " %-20s %s\n" $opt "$desc" printf " %-20s %s\n" $opt "$desc"
...@@ -525,5 +524,6 @@ is_active_systemd() ...@@ -525,5 +524,6 @@ is_active_systemd()
a='' mountpoint -q "$SYSTEMD_CGROUP_DIR" || return a='' mountpoint -q "$SYSTEMD_CGROUP_DIR" || return
readlink /sbin/init | grep -q 'systemd' || return readlink /sbin/init | grep -q 'systemd' || return
# some hack # some hack
# shellcheck disable=SC2009
ps ax | grep '[s]ystemd' | grep -q -v 'systemd-udev' ps ax | grep '[s]ystemd' | grep -q -v 'systemd-udev'
} }
...@@ -145,7 +145,11 @@ epm_simulate() ...@@ -145,7 +145,11 @@ epm_simulate()
_epm_do_simulate $filenames _epm_do_simulate $filenames
local RES=$? local RES=$?
if [ -z "$quiet" ] ; then if [ -z "$quiet" ] ; then
[ "$RES" = 0 ] && info "Simulate result: $filenames package(s) CAN BE installed" || info "Simulate result: There are PROBLEMS with install some package(s)" if [ "$RES" = 0 ] ; then
info "Simulate result: $filenames package(s) CAN BE installed"
else
info "Simulate result: There are PROBLEMS with install some package(s)"
fi
fi fi
return $RES return $RES
} }
......
...@@ -35,7 +35,7 @@ get_pao_var() ...@@ -35,7 +35,7 @@ get_pao_var()
{ {
local FIELD="$1" local FIELD="$1"
#grep '"$FIELD"' | sed -e 's|.*"$FIELD":"||g' | sed -e 's|".*||g' #grep '"$FIELD"' | sed -e 's|.*"$FIELD":"||g' | sed -e 's|".*||g'
$SHAREDIR/tools_json -b | egrep "\[.*\"$FIELD\"\]" | sed -e 's|.*[[:space:]]"\(.*\)"|\1|g' $SHAREDIR/tools_json -b | grep -E "\[.*\"$FIELD\"\]" | sed -e 's|.*[[:space:]]"\(.*\)"|\1|g'
return 0 return 0
} }
......
...@@ -94,6 +94,7 @@ epm_upgrade() ...@@ -94,6 +94,7 @@ epm_upgrade()
CMD="guix package -u" CMD="guix package -u"
;; ;;
aptcyg) aptcyg)
# shellcheck disable=SC2046
docmd_foreach "epm install" $(short=1 epm packages) docmd_foreach "epm install" $(short=1 epm packages)
return return
;; ;;
......
...@@ -70,7 +70,7 @@ create_fake_files() ...@@ -70,7 +70,7 @@ create_fake_files()
DIRALLFILES="$MYTMPDIR/files/" DIRALLFILES="$MYTMPDIR/files/"
mkdir -p "$DIRALLFILES" mkdir -p "$DIRALLFILES"
print_files | while read line ; do print_files | while read -r line ; do
touch $DIRALLFILES/$(basename "$line") touch $DIRALLFILES/$(basename "$line")
done done
} }
......
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