From: Larry W. Virden on
On Sep 11, 5:36 am, Jonathan Bromley <jonathan.brom...(a)MYCOMPANY.com>
wrote:
> This is probably a painfully basic question, sorry.
>
> We have [file split] and [file join] for all the
> right reasons.  But what should I do if I want the
> inverse operation of [file split], i.e. reassemble
> a list of path components into a platform-appropriate
> pathname?
>

For the casual reader passing by, who like me, often finds themselves
with less knowledge of tcl than they need, there's a reason why
Jonathan is asking for an alternative to file join to put together a
file split.

$ tclsh
% set a {/a/b/c}
/a/b/c
% set b [file split $a]
/ a b c
% set c [file join $b]
/ a b c

The issue is this - file join expects a series of arguments, which it
will then join together. However, file split returns a list containing
the arguments of the original path broken down.

The examples using the eval and the if are "flattening" the list of
arguments into separate arguments. Of course, if someone were free to
do so, they could use
% set d [file join {*}$b]
/a/b/c

However, as Jonathan pointed out, he is restricted in the version of
Tcl that he is using. So he has to revert to the old paradigm of using
some sort of eval process to flatten the list into seperate arguments.