sm-commit AT lists.ibiblio.org
Subject: Source Mage code commit list
List archive
[SM-Commit] GIT changes to master sorcery by Jaka Kranjc (4b3df9676221ab1b3d16be51f7312ef3f88773d6)
- From: Jaka Kranjc <scm AT sourcemage.org>
- To: sm-commit AT lists.ibiblio.org
- Subject: [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (4b3df9676221ab1b3d16be51f7312ef3f88773d6)
- Date: Fri, 22 Aug 2008 11:21:55 -0500
GIT changes to master sorcery by Jaka Kranjc <lynxlynxlynx AT sourcemage.org>:
ChangeLog | 4 ---
var/lib/sorcery/modules/libmisc | 50
++++++++++++++++++++++------------------
2 files changed, 28 insertions(+), 26 deletions(-)
New commits:
commit 4b3df9676221ab1b3d16be51f7312ef3f88773d6
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Revert " libmisc: reverted smgl_dirname to the simpler previous
implementation"
hah, didn't catch this one with 23 tests :)
This reverts commit 48252af0b025f7e95699569971b087764f244a69.
Conflicts:
ChangeLog
diff --git a/ChangeLog b/ChangeLog
index 83f75d2..d675669 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,10 +6,6 @@
2008-08-21 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
* libtablet: REPAIR^all can now "repair" non-existing files
-2008-08-20 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
- * libmisc: reverted smgl_dirname to the simpler previous
implementation
- and added a oneliner to make it pass all the unit tests
-
2008-08-19 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
* cast: exit 1 when falling in an INT/TERM trap
* dl_git: use the multicall git binary; the hardlinks aren't available
diff --git a/var/lib/sorcery/modules/libmisc b/var/lib/sorcery/modules/libmisc
index 4dbeea8..e37791e 100755
--- a/var/lib/sorcery/modules/libmisc
+++ b/var/lib/sorcery/modules/libmisc
@@ -1437,38 +1437,44 @@ function awkuniq() {
## Dirname written in bash, optionally uses an upvar (making it forkless).
#---------------------------------------------------------------------
function smgl_dirname() {
- local __dir=$1
- local __last_dir __next_dir
+ local __dir=() __dirname i __last_dir
# Pull of any trailing /'s, there could be more than/one///
- while [[ "$__dir" != "$__last_dir" ]] ; do
- __last_dir=$__dir
- __dir=${__dir%/}
+ __dirname=$1
+ while [[ $__dirname != $__last_dir ]]; do
+ __last_dir=$__dirname
+ __dirname=${__dirname%/}
done
+ if [[ -z $__dirname ]]; then
+ __dirname=/
+ fi
- # remove the basename
- __next_dir=${__dir%/*}
- # make level one (/bin) directories work
- [[ -z $__next_dir ]] && __next_dir=//
+ explode "$__dirname" / __dir
+ [[ ${__dirname:0:1} == / ]] && unset __dirname || __dirname="."
+ for (( i=0; i < ${#__dir[@]}-1; i++ )); do
+ __dirname="$__dirname/${__dir[$i]}"
+ done
- # if the string had no more directory seperators in it (was aaa/, now aaa),
- # then this is a special case, the answer is '.'
- if [[ "$__next_dir" == "$__dir" ]] ; then
- __dir="."
+ # Pull of any trailing /'s
+ while [[ $__dirname != $__last_dir ]]; do
+ __last_dir=$__dirname
+ __dirname=${__dirname%/}
+ done
+ if [[ -z $__dirname ]]; then
+ __dirname=/
else
- __dir=$__next_dir
- # Trim off anymore leading /'s (was /aa//bb, now /aa//)
- while [[ "$__dir" != "$__last_dir" ]] ; do
- __last_dir=$__dir
- __dir=${__dir%/}
- [[ "$__dir" == "/" ]] && break
- done
+ if [[ ${__dirname:0:2} == // ]]; then
+ __dirname="${__dirname:1}"
+ elif [[ ${__dirname:0:2} == ./ ]]; then
+ # usually not strictly necessary, but let's be conformant with dirname
+ __dirname="${__dirname:2}"
+ fi
fi
if [[ "$2" ]] ; then
- upvar "$2" "$__dir"
+ upvar "$2" "$__dirname"
else
- echo "$__dir"
+ echo "$__dirname"
fi
}
- [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (4b3df9676221ab1b3d16be51f7312ef3f88773d6), Jaka Kranjc, 08/22/2008
Archive powered by MHonArc 2.6.24.