Commit a73ad379 authored by Vitaly Lipatov's avatar Vitaly Lipatov

make shellcheck happy

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