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
> 
> 
> With sed 's#//*#/#g':

I did the same but was fooled by busybox's 'sed -e' which did not behave

now this is close to what it should be

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


here is the output

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

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

cheers

Erich



Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

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

Reply via email to