5

There are three types of file names

First (rooted below some kind of "current working directory")

../foo 
./foo
bar/foo # really in this group?

And (rooted in an absolute path, independent of the CWD)

/foo
/bar/foo

And (independent of the CWD and independent of any absolute path)

foo
bar/foo # really in this group?

I'm unsure where to put the bar/foo thing in. Is there a general naming convention for these three categories? Or are there more of them?

Fred Foo
  • 355,277
  • 75
  • 744
  • 836
Johannes Schaub - litb
  • 496,577
  • 130
  • 894
  • 1,212
  • Is this really a *programming* question ? – Paul R Jul 14 '11 at 11:34
  • @Paul R: it's a good question if you want to know how to name your variables :) – Fred Foo Jul 14 '11 at 11:54
  • Re: *And (independent of the CWD and independent of any absolute path)*   Those are *not* independant of the cwd, they are **in** the cwd and thus relative. – Synetech Apr 11 '12 at 05:00
  • @Synetech but why then typing "ls" finds a program file in "/usr/bin/" instead of "." ? It does not look in the CWD, but in directories of $PATH. Which indicates that names of the form "foo" are of some other category. Relative perhaps, but do they deserve a special name like "context-relative" or something? – Johannes Schaub - litb Feb 11 '16 at 16:00

1 Answers1

1

foo is also a relative pathname. Any path not containing a directory separator is relative to the current directory .

In another taxonomy, you could call foo a basename; then bar/foo moves to the first category.

Fred Foo
  • 355,277
  • 75
  • 744
  • 836
  • "Any path not containing a directory separator is relative to the current directory .". But executing "echo" finds /bin/echo. Not necessarily "./echo". While when I execute "./echo", it doesn'T find "/bin/echo". So "foo" and "./foo" seem to be different; the former doesn't seem to be relative to the current directory. – Johannes Schaub - litb Jul 14 '11 at 12:05
  • 1
    "foo" seems to be like "relative to something context dependent, but not necessarily the CWD". For example, program execution uses PATH, library loading uses, among others, LD_LIBRARY_PATH. – Johannes Schaub - litb Jul 14 '11 at 12:06
  • @litb: alright, but this behavior is only found in a select number of cases (shell commands etc.) and I've never seen a name for this, so you can coin one yourself. What about "search-path relative"? – Fred Foo Jul 14 '11 at 12:37