Use absolutize_paths to make userdir and path absolute by jtulach · Pull Request #8998 · apache/netbeans (original) (raw)

@jtulach please have a look at this code:

old=`pwd`
cd "$progdir"/..
basedir=`pwd`
cd "$old"

I think this is what @neilcsmith-net meant by "a different way to how other paths are absolutized". My understanding is, that this saves the current directory into variable old, then cds to the path denoted by parent of $progdir. Invoking pwd will now give you the path when the parent of $progdir is resolved against the current directory. That value is stored into $basedir for later usage. As we are now at the wrong location in the directory tree, we cd back into the start directory (using the value from $old).

This might not be the most efficient way, but it looks sane to me and is small enough to be copyable (IMHO).

As a test you can create resolve.sh like this:

#!/bin/bash

old=pwd cd "$1" resolved=pwd cd "$old"

echo "Resolved path: '$resolved'";

In my test session my shell is opened in /home/matthias/test, now I get:

matthias@enterprise:~/test$ resolve.sh ../tmp/yubikey\ pkcs11\ broken/src/
Resolved path: '/home/matthias/tmp/yubikey pkcs11 broken/src'
matthias@enterprise:~/test$

Which is the expected answer.