diff --git a/common/environment/setup/install.sh b/common/environment/setup/install.sh index dbb792f592..b56e17a437 100644 --- a/common/environment/setup/install.sh +++ b/common/environment/setup/install.sh @@ -147,9 +147,9 @@ _vinstall() { fi if [ -z "$targetfile" ]; then - install -Dm${mode} ${file} "${_destdir}/${targetdir}/$(basename ${file})" + install -Dm${mode} ${file} "${_destdir}/${targetdir}/${file##*/}" else - install -Dm${mode} ${file} "${_destdir}/${targetdir}/$(basename ${targetfile})" + install -Dm${mode} ${file} "${_destdir}/${targetdir}/${targetfile##*/}" fi } diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh index ee59623366..16fe0e9742 100644 --- a/common/hooks/do-fetch/00-distfiles.sh +++ b/common/hooks/do-fetch/00-distfiles.sh @@ -55,7 +55,7 @@ try_mirrors() { local curfile="$1" distfile="$2" dfcount="$3" subdir="$4" f="$5" local filesum cksum basefile mirror path scheme [ -z "$XBPS_DISTFILES_MIRROR" ] && return - basefile="$(basename $f)" + basefile="${f##*/}" cksum=$(get_cksum $curfile $dfcount) for mirror in $XBPS_DISTFILES_MIRROR; do scheme="file" diff --git a/common/hooks/post-extract/00-patches.sh b/common/hooks/post-extract/00-patches.sh index 2cef5f24c1..73caa6dd1f 100644 --- a/common/hooks/post-extract/00-patches.sh +++ b/common/hooks/post-extract/00-patches.sh @@ -4,7 +4,8 @@ _process_patch() { local _args= _patch= i=$1 _args="-Np0" - _patch=$(basename $i) + _patch=${i##*/} + if [ -f $PATCHESDIR/${_patch}.args ]; then _args=$(cat $PATCHESDIR/${_patch}.args) elif [ -n "$patch_args" ]; then diff --git a/common/hooks/post-install/00-compress-info-files.sh b/common/hooks/post-install/00-compress-info-files.sh index f76e6eebb1..6ae8c13288 100644 --- a/common/hooks/post-install/00-compress-info-files.sh +++ b/common/hooks/post-install/00-compress-info-files.sh @@ -32,7 +32,7 @@ hook() { if [ -h ${PKGDESTDIR}/"$j" ]; then dirat=$(dirname "$j") lnkat=$(readlink ${PKGDESTDIR}/"$j") - newlnk=$(basename "$j") + newlnk="${j##*/}" rm -f ${PKGDESTDIR}/"$j" cd ${PKGDESTDIR}/"$dirat" ln -s "${lnkat}".gz "${newlnk}".gz diff --git a/common/hooks/post-install/04-create-xbps-metadata-scripts.sh b/common/hooks/post-install/04-create-xbps-metadata-scripts.sh index 90704ff16f..36dbc8c72f 100644 --- a/common/hooks/post-install/04-create-xbps-metadata-scripts.sh +++ b/common/hooks/post-install/04-create-xbps-metadata-scripts.sh @@ -205,7 +205,7 @@ _EOF if [ -d ${PKGDESTDIR}/usr/share/gconf/schemas ]; then _add_trigger gconf-schemas for f in ${PKGDESTDIR}/usr/share/gconf/schemas/*.schemas; do - _schemas="${_schemas} $(basename $f)" + _schemas="${_schemas} ${f##*/}" done echo "export gconf_schemas=\"${_schemas}\"" >> $tmpf fi diff --git a/common/hooks/post-install/06-strip-and-debug-pkgs.sh b/common/hooks/post-install/06-strip-and-debug-pkgs.sh index 9bc66c7aa7..7e8ddfc80b 100644 --- a/common/hooks/post-install/06-strip-and-debug-pkgs.sh +++ b/common/hooks/post-install/06-strip-and-debug-pkgs.sh @@ -8,7 +8,7 @@ make_debug() { [ -n "$nodebug" ] && return 0 dname=$(echo "$(dirname $1)"|sed -e "s|${PKGDESTDIR}||g") - fname="$(basename $1)" + fname="${1##*/}" dbgfile="${dname}/${fname}" mkdir -p "${PKGDESTDIR}/usr/lib/debug/${dname}" @@ -27,7 +27,7 @@ attach_debug() { [ -n "$nodebug" ] && return 0 dname=$(echo "$(dirname $1)"|sed -e "s|${PKGDESTDIR}||g") - fname="$(basename $1)" + fname="${1##*/}" dbgfile="${dname}/${fname}" $OBJCOPY --add-gnu-debuglink="${PKGDESTDIR}/usr/lib/debug/${dbgfile}" "$1" @@ -69,7 +69,7 @@ hook() { continue fi - fname=$(basename "$f") + fname=${f##*/} for x in ${nostrip_files}; do if [ "$x" = "$fname" ]; then found=1 diff --git a/common/hooks/pre-configure/02-script-wrapper.sh b/common/hooks/pre-configure/02-script-wrapper.sh index ab5cee7aa2..ea4eea4529 100644 --- a/common/hooks/pre-configure/02-script-wrapper.sh +++ b/common/hooks/pre-configure/02-script-wrapper.sh @@ -79,8 +79,12 @@ _EOF } install_wrappers() { + local fname + for f in ${XBPS_COMMONDIR}/wrappers/*.sh; do - install -m0755 ${f} ${XBPS_WRAPPERDIR}/$(basename ${f%.sh}) + fname=${f##*/} + fname=${fname%.sh} + install -m0755 ${f} ${XBPS_WRAPPERDIR}/${fname} done } diff --git a/common/hooks/pre-pkg/06-shlib-provides.sh b/common/hooks/pre-pkg/06-shlib-provides.sh index d23a1d1210..99ec8653c8 100644 --- a/common/hooks/pre-pkg/06-shlib-provides.sh +++ b/common/hooks/pre-pkg/06-shlib-provides.sh @@ -13,7 +13,7 @@ collect_sonames() { # real pkg find ${_destdir} -type f -name "*.so*" | while read f; do - _fname=$(basename "$f") + _fname="${f##*/}" case "$(file -bi "$f")" in application/x-sharedlib*) # shared library diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh index 710f4801b4..25ffdff511 100755 --- a/common/xbps-src/libexec/build.sh +++ b/common/xbps-src/libexec/build.sh @@ -10,7 +10,7 @@ # $5 - internal [OPTIONAL] if [ $# -lt 3 -o $# -gt 5 ]; then - echo "$(basename $0): invalid number of arguments: pkgname targetpkg target [cross-target]" + echo "${0##*/}: invalid number of arguments: pkgname targetpkg target [cross-target]" exit 1 fi diff --git a/common/xbps-src/libexec/xbps-src-dobuild.sh b/common/xbps-src/libexec/xbps-src-dobuild.sh index bf56ab76a4..e0f4cfc682 100755 --- a/common/xbps-src/libexec/xbps-src-dobuild.sh +++ b/common/xbps-src/libexec/xbps-src-dobuild.sh @@ -7,7 +7,7 @@ # $2 - cross target [OPTIONAL] if [ $# -lt 1 -o $# -gt 2 ]; then - echo "$(basename $0): invalid number of arguments: pkgname [cross-target]" + echo "${0##*/}: invalid number of arguments: pkgname [cross-target]" exit 1 fi diff --git a/common/xbps-src/libexec/xbps-src-doconfigure.sh b/common/xbps-src/libexec/xbps-src-doconfigure.sh index e53e1855a3..8e33ba6fe1 100755 --- a/common/xbps-src/libexec/xbps-src-doconfigure.sh +++ b/common/xbps-src/libexec/xbps-src-doconfigure.sh @@ -7,7 +7,7 @@ # $2 - cross target [OPTIONAL] if [ $# -lt 1 -o $# -gt 2 ]; then - echo "$(basename $0): invalid number of arguments: pkgname [cross-target]" + echo "${0##*/}: invalid number of arguments: pkgname [cross-target]" exit 1 fi diff --git a/common/xbps-src/libexec/xbps-src-doextract.sh b/common/xbps-src/libexec/xbps-src-doextract.sh index d3f93bbd06..20358736c2 100755 --- a/common/xbps-src/libexec/xbps-src-doextract.sh +++ b/common/xbps-src/libexec/xbps-src-doextract.sh @@ -7,7 +7,7 @@ # $2 - cross target [OPTIONAL] if [ $# -lt 1 -o $# -gt 2 ]; then - echo "$(basename $0): invalid number of arguments: pkgname [cross-target]" + echo "${0##*/}: invalid number of arguments: pkgname [cross-target]" exit 1 fi diff --git a/common/xbps-src/libexec/xbps-src-dofetch.sh b/common/xbps-src/libexec/xbps-src-dofetch.sh index b1060edd82..f7100cbcab 100755 --- a/common/xbps-src/libexec/xbps-src-dofetch.sh +++ b/common/xbps-src/libexec/xbps-src-dofetch.sh @@ -7,7 +7,7 @@ # $2 - cross target [OPTIONAL] if [ $# -lt 1 -o $# -gt 2 ]; then - echo "$(basename $0): invalid number of arguments: pkgname [cross-target]" + echo "${0##*/}: invalid number of arguments: pkgname [cross-target]" exit 1 fi diff --git a/common/xbps-src/libexec/xbps-src-doinstall.sh b/common/xbps-src/libexec/xbps-src-doinstall.sh index c8165273a6..c9c2225bb9 100755 --- a/common/xbps-src/libexec/xbps-src-doinstall.sh +++ b/common/xbps-src/libexec/xbps-src-doinstall.sh @@ -7,7 +7,7 @@ # $2 - cross target [OPTIONAL] if [ $# -lt 1 -o $# -gt 2 ]; then - echo "$(basename $0): invalid number of arguments: pkgname [cross-target]" + echo "${0##*/}: invalid number of arguments: pkgname [cross-target]" exit 1 fi diff --git a/common/xbps-src/libexec/xbps-src-dopkg.sh b/common/xbps-src/libexec/xbps-src-dopkg.sh index a60d02c70e..f367634e08 100755 --- a/common/xbps-src/libexec/xbps-src-dopkg.sh +++ b/common/xbps-src/libexec/xbps-src-dopkg.sh @@ -8,7 +8,7 @@ # $3 - cross-target [OPTIONAL] if [ $# -lt 2 -o $# -gt 3 ]; then - echo "$(basename $0): invalid number of arguments: pkgname repository [cross-target]" + echo "${0##*/}: invalid number of arguments: pkgname repository [cross-target]" exit 1 fi diff --git a/common/xbps-src/libexec/xbps-src-prepkg.sh b/common/xbps-src/libexec/xbps-src-prepkg.sh index 81fbca1f5e..7f6c4ad47b 100755 --- a/common/xbps-src/libexec/xbps-src-prepkg.sh +++ b/common/xbps-src/libexec/xbps-src-prepkg.sh @@ -7,7 +7,7 @@ # $2 - cross target [OPTIONAL] if [ $# -lt 1 -o $# -gt 2 ]; then - echo "$(basename $0): invalid number of arguments: pkgname [cross-target]" + echo "${0##*/}: invalid number of arguments: pkgname [cross-target]" exit 1 fi diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh index 75d9234060..f979e0d65c 100644 --- a/common/xbps-src/shutils/bulk.sh +++ b/common/xbps-src/shutils/bulk.sh @@ -1,7 +1,7 @@ # vim: set ts=4 sw=4 et: bulk_getlink() { - local p="$(basename $1)" + local p="${1##*/}" local target="$(readlink $XBPS_SRCPKGDIR/$p)" if [ $? -eq 0 -a -n "$target" ]; then diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh index 4795cd4bdc..bd7f918e26 100644 --- a/common/xbps-src/shutils/common.sh +++ b/common/xbps-src/shutils/common.sh @@ -182,7 +182,7 @@ run_pkg_hooks() { eval unset -f hook for f in ${XBPS_COMMONDIR}/hooks/${phase}/*.sh; do [ ! -r $f ] && continue - hookn=$(basename $f) + hookn=${f##*/} hookn=${hookn%.sh} . $f run_func hook "$phase hook: $hookn" ${phase}_${hookn} diff --git a/common/xbps-src/shutils/purge_distfiles.sh b/common/xbps-src/shutils/purge_distfiles.sh index 857bb3f863..b5976b443c 100755 --- a/common/xbps-src/shutils/purge_distfiles.sh +++ b/common/xbps-src/shutils/purge_distfiles.sh @@ -75,7 +75,7 @@ purge_distfiles() { hashes=($XBPS_SRCDISTDIR/by_sha256/*) readonly HASHLEN=64 for file in ${hashes[@]}; do - hash_distfile=$(basename "$file") + hash_distfile=${file##*/} hash=${hash_distfile:0:$HASHLEN} [ -n "${my_hashes[$hash]}" ] && continue inode=$(stat "$file" --printf "%i") diff --git a/common/xbps-src/shutils/update_hash_cache.sh b/common/xbps-src/shutils/update_hash_cache.sh index c45932ce30..b879536dd8 100644 --- a/common/xbps-src/shutils/update_hash_cache.sh +++ b/common/xbps-src/shutils/update_hash_cache.sh @@ -6,7 +6,7 @@ update_hash_cache() { mkdir -p "$cache" find "$XBPS_SRCDISTDIR" -type f | grep -v by_sha256 | while read -r distfile; do cksum=$(cat "$distfile" | sha256sum | cut -d " " -f 1) - curfile="$(basename ${distfile})" + curfile="${distfile##*/}" ln -vf "$distfile" "${cache}/${cksum}_${curfile}" done }