Hey Erich,

Your expand path properly handles the './', and also, another thing I 
discovered is that with my modified expandpath, it will not always get rid of 
redundant slashes:

my modified expandpath():

//foo/bar = /foo/bar

but then:

/foo = //foo

!?

Your expandpath seems to do what it's supposed to, but the only exception is 
that it doesn't retain the slash when $1 is just a slash:

`expandpath2 /` = ""


Nothing. But you're also saying that my expandpath does that too? I haven't 
been able to replicate that.

Anyhow, if you can keep the slash when just '/' is passed, then that's all 
that's needed.



----- Original Message -----
From: Erich Titl <erich.t...@think.ch>
To: cpu memhd <cpume...@yahoo.com>; leaf-devel 
<leaf-devel@lists.sourceforge.net>
Cc: 
Sent: Sunday, November 2, 2014 1:17 AM
Subject: Re: [leaf-devel] Fwd: [leaf:bering-uclibc] [2bdcfd] - Jorge Contreras: 
Backup symlinks, empty dirs and other improvements

Hi Jorge

Am 02.11.2014 um 02:48 schrieb cpu memhd:
> What I use to get rid of redundant slashes is: sed 's#//*#/#g'
> Currently:
> 
> expandpath2 /somedir/eh///he/ = /somedir/eh///he
> 

I compared your rewritten expandpath with my latest version

expandpath2 () {
        case $1 in
                /*)     echo $1 | sed 's!//*!/!g; s!/*$!!' ;;
                *)      echo `pwd`/`echo $1 | sed 's!//*!/!g;
s!^\./*!!g'` | sed 's!/*$!!' ;;
        esac
}

running expandpath on ./foo////bar///baz////
expandpath = /tmp/./foo/bar/baz

running expandpath2 on ./foo////bar///baz////
expandpath2 = /tmp/foo/bar/baz
hit any key to continue...




cheers

Erich

------------------------------------------------------------------------------

_______________________________________________
leaf-devel mailing list
leaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/leaf-devel

Reply via email to