best way to build an absolute spec

O

oldyork90

I have a directory $my_dir. I test this with -d.
$my_dir is user defined.

I want to build the file spec "$my_dir . $my_fn", but $my_dir may be
constructed as either /one/two or /one/two/.

I could test for the trailing path separator and act accordingly, but is
there a better way, a "standard" or best practice way, of doing this?

How do you pros build the absolute paths?


I find that in Windows "/one/two//my_file" will work, but I'd rather not.

Thanks in advance.
 
R

Rainer Weikusat

I have a directory $my_dir. I test this with -d.
$my_dir is user defined.

I want to build the file spec "$my_dir . $my_fn", but $my_dir may be
constructed as either /one/two or /one/two/.

I could test for the trailing path separator and act accordingly, but is
there a better way, a "standard" or best practice way, of doing this?

How do you pros build the absolute paths?


I find that in Windows "/one/two//my_file" will work, but I'd rather
not.

POSIX/ UNIX(*) pathnames may separate two components with any number of
/-characters (subject to pathname lenght limits).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top