> Le 4 nov. 2014 à 00:26, Erich Titl <erich.t...@think.ch> a écrit :
> 
> HI Jorge
> 
> Am 03.11.2014 um 21:50 schrieb cpu memhd:
>> 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.
> 
> That is pretty easy
> 
> either
> 
> expandpath () {
>        case $1 in
>                /*)     echo $1 | sed 's!//*!/!g' ;;
>                *)      echo `pwd`/`echo $1 | sed 's!//*!/!g; s!^\./*!!g'`;;
>        esac
>       }
> 
> which always retains a trailing slash
> 
> or
> 
> expandpath () {
>        case $1 in
>                /)      echo $1 | sed 's!//*!/!g' ;;
>                /*)     echo $1 | sed 's!//*!/!g; s!/$!!' ;;
>                *)      echo `pwd`/`echo $1 | sed 's!//*!/!g;
> s!^\./*!!g'` | sed 's!/$!!' ;;
>        esac
>       }
> 
> which only retains it in the case of a single slash.

Hi all, i don’t know if it can help you but i have write some functions to 
retrieve abspath or relative path from a path.
You can see the functions in the utils.lib file: 
https://github.com/LEAF-Bering-uClibc/bering-uclibc/blob/master/tools/utils.lib

Regards,
Yves
------------------------------------------------------------------------------

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

Reply via email to