software 

the best and worst implementation of realpath I've seen:

sed '/^[^/]/s@^@'"$PWD"'/@
s@/\.\.$@/../@;s@/\(\./\)\{1,\}@/@g;:0
s@[^/][^/]*//*\.\./@/@;t 0
s@^/*\.\./@/@;s@//*@/@g;s@/\.\{0,1\}$@@;s@^$@/@'

from github.com/clvv/fasd/blob/90b5

software 

As far as I can tell, it works!

echo '..' | sed ..... => /home

echo 'foo/../foo' | sed ... => /home/esk/foo

But also why does this exist

Follow

software 

Original commit that added it doesn't totally answer why it exists, but I guess it's the best I'll get for now. It was a lot shorter back then too!

github.com/clvv/fasd/commit/27

· · Web · 0 · 0 · 0
Sign in to participate in the conversation
Wobscale Social

wobscale.social - a server for friends of the Wob, affiliated with Wobscale Technologies