From 83dd37ec007c0244b23241be4c6a134f8b993c28 Mon Sep 17 00:00:00 2001 From: rhatto Date: Sun, 30 Aug 2009 22:16:15 +0000 Subject: Cleanup and bugfix for #94 and #95 git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@812 04377dda-e619-0410-9926-eae83683ac58 --- trunk/lib/common.sh | 45 +++++++++++++++------------------------------ 1 file changed, 15 insertions(+), 30 deletions(-) (limited to 'trunk/lib') diff --git a/trunk/lib/common.sh b/trunk/lib/common.sh index 2453099..f05b276 100644 --- a/trunk/lib/common.sh +++ b/trunk/lib/common.sh @@ -32,7 +32,17 @@ SIMPLARET="simplaret" function pkg_ext { # list all possible package extensions - echo .tgz .tbz .tlz .txz + local ext exts + + for ext in tgz tbz tlz txz; do + if [ ! -z "$1" ]; then + exts="$exts $1.$ext" + else + exts="$exts $ext" + fi + done + + echo $exts } @@ -41,16 +51,7 @@ function pkg_ext_grep { # list all possible package extensions # grep extended regexp version - local period - - if [ "$1" == "." ]; then - $period="." - fi - - for ext in `pkg_ext`; do - exts="$exts|$period$ext" - done - echo $exts + echo "($(pkg_ext $1))" | sed -e 's/ /|/g' } @@ -59,18 +60,7 @@ function pkg_ext_sed { # list all possible package extensions # sed regexp version - local period - - if [ "$1" == "." ]; then - $period="." - fi - - exts="\(" - for ext in `pkg_ext`; do - exts="$exts\|$period$ext" - done - exts="\)" - echo $exts + echo "($(pkg_ext $1))" | sed -e 's/ /\\|/g' } @@ -87,12 +77,7 @@ function pkg_ext_find { match="*" fi - exts="(" - for ext in `pkg_ext`; do - exts="$exts -or -name $match.$ext" - done - exts=")" - echo $exts + echo "($(pkg_ext $match))" | sed -e 's/ / -or -name /g' } @@ -101,7 +86,7 @@ function strip_basename { file="$1" shift for ext in $*; do - file="`basename $file $ext`" + file="`basename $file .$ext`" done echo $file -- cgit v1.2.3