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

Follow

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

· · Web · 0 · 0 · 0

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

Sign in to participate in the conversation
Wobscale Social

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!