Add a real path computation

Many commands need a path as an argument. This path can be absolute or
relative. The key is to understand where the command will operate. For
example, when using `cd`, we need to know where we'll end up after
running the command.  And with `set`, we want to know what will be
modified. This change creates a general function called realPath() that
takes the current working directory (cwd) and the given path as
arguments, and then gives back the final path.  Doing this makes the
code easier to read and more compact because we'll use it several times
in the next changes.

Change-Id: Id940062525b64eed1de438407ff8ae2cfbcdde6d
diff --git a/src/ast_path.cpp b/src/ast_path.cpp
index e0348db..b34817b 100644
--- a/src/ast_path.cpp
+++ b/src/ast_path.cpp
@@ -359,3 +359,16 @@
     impl_pushFragment(m_nodes, fragment);
     validatePathNodes(m_nodes);
 }
+
+dataPath_ realPath(const dataPath_& cwd, const dataPath_& newPath)
+{
+    if (newPath.m_scope == Scope::Absolute) {
+        return newPath;
+    }
+
+    dataPath_ res = cwd;
+    for (const auto& it : newPath.m_nodes) {
+        res.pushFragment(it);
+    }
+    return res;
+}