aboutsummaryrefslogtreecommitdiff
path: root/trunk/lib/common.sh
diff options
context:
space:
mode:
Diffstat (limited to 'trunk/lib/common.sh')
-rw-r--r--trunk/lib/common.sh45
1 files changed, 15 insertions, 30 deletions
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