return the closest enclosing directory
Replace a group in the execution string, using
data from the user input and from the selected line
Improve the path to try remove and solve .. token.
Build a usable path from a user input which may be absolute
(if it starts with / or ~) or relative to the supplied base_dir.
(we might want to try detect windows drives in the future, too)
If the input has a tilde as first complete element, replace it
with the user’s home directory. Return the input as a path without
transformation in other cases