diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | libs/core.bash.in | 21 | ||||
-rw-r--r-- | modules/bashcomp.eselect | 10 |
3 files changed, 28 insertions, 12 deletions
@@ -1,5 +1,12 @@ ChangeLog for eselect +2005-07-03 Aaron Walker <ka0ttic@gentoo.org> + + * libs/core.bash.in: Added dirname/basename wrapper functions which use + bash instead of launching their external counterparts. + * modules/bashcomp.eselect: Use basename instead of ${var##*/} + constructs. + 2005-06-19 Danny van Dyk <kugelfang@gentoo.org> * libs/output.bash.in: Watch out for escaped spaces and concatenate @@ -14,7 +21,7 @@ ChangeLog for eselect * Tagged 0.9.5 release. * acinclude.m4: Added ES_PROG_GNU_SED macro for checking the path to GNU sed. This allows eselect to work on platforms where GNU sed is - gsed. + "gsed" not "sed". * configure.ac: Update version; added call to our new ES_PROG_GNU_SED macro. * libs/core.bash.in: Added 'sed() { @SED@ $* ; }' so that everything diff --git a/libs/core.bash.in b/libs/core.bash.in index 0b9648a..a7e7793 100644 --- a/libs/core.bash.in +++ b/libs/core.bash.in @@ -17,12 +17,6 @@ # eselect; if not, write to the Free Software Foundation, Inc., 59 Temple # Place, Suite 330, Boston, MA 02111-1307 USA -# sed PUBLIC -# GNU sed wrapper (real path to GNU sed determined by configure) -sed() { - %SED% "$@" -} - # die [-q] "Message" PUBLIC # Display "Message" as an error. If -q is not provided, gives a stacktrace. die() { @@ -119,4 +113,19 @@ eval() { die "Don't use eval. Find another way." } +# GNU sed wrapper (real path to GNU sed determined by configure) +sed() { + %SED% "$@" +} + +# basename wrapper +basename() { + echo ${1##*/} +} + +# dirname wrapper +dirname() { + echo ${1%/*} +} + # vim: set sw=4 et sts=4 tw=80 : diff --git a/modules/bashcomp.eselect b/modules/bashcomp.eselect index a4214e5..1f94dcd 100644 --- a/modules/bashcomp.eselect +++ b/modules/bashcomp.eselect @@ -18,7 +18,7 @@ find_targets() { fi for bc in ${bcdirs[@]} ; do - [[ -e ${bc} && ${bc} != *~ ]] && targets="${targets}\n${bc##*/}" + [[ -e ${bc} && ${bc} != *~ ]] && targets="${targets}\n$(basename ${bc})" done echo -ne ${targets} | sort -u @@ -107,7 +107,7 @@ do_enable() { [[ -z ${1} ]] && die -q "You didn't specify any completions to enable." # create directory if necessary - if [[ ! -d ${bcdir} && -w ${bcdir%/*} ]] ; then + if [[ ! -d ${bcdir} && -w $(dirname ${bcdir}) ]] ; then mkdir ${bcdir} || die -q "Failed to create ${bcdir}" elif [[ ! -d ${bcdir} ]] ; then die -q "You don't have permission to create ${bcdir}" @@ -172,8 +172,8 @@ do_enable() { fi # already installed? - if [[ -e ${bcdir}/${bc##*/} ]] ; then - write_error_msg "${bc##*/} is already installed" + if [[ -e ${bcdir}/$(basename ${bc}) ]] ; then + write_error_msg "$(basename ${bc}) is already installed" continue fi @@ -223,7 +223,7 @@ do_disable() { fi # remove it if we have permissions - if [[ -w ${file%/*} ]] ; then + if [[ -w $(dirname ${file}) ]] ; then rm "${file}" || die -q "Failed to remove ${file}" else die -q "You don't have permission to remove ${file}" |