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.
cheers
Erich
smime.p7s
Description: S/MIME Cryptographic Signature
------------------------------------------------------------------------------
_______________________________________________ leaf-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/leaf-devel
