realpath -- convert a filename to one passing through no symbolic links
Synopsis
-
- Usage:
realpath fn
-
Inputs:
-
fn, a string, a filename, or path to a file
-
Outputs:
-
a string, a pathname to fn passing through no symbolic links, and ending with a slash if fn refers to a directory
Description
i1 : realpath "."
o1 = /tmp/M2-499257-0/76-rundir/
|
i2 : p = temporaryFileName()
o2 = /tmp/M2-500153-0/0
|
i3 : q = temporaryFileName()
o3 = /tmp/M2-500153-0/1
|
i4 : symlinkFile(p,q)
|
i5 : p << close
o5 = /tmp/M2-500153-0/0
o5 : File
|
i6 : readlink q
o6 = /tmp/M2-500153-0/0
|
i7 : realpath q
o7 = /tmp/M2-500153-0/0
|
i8 : removeFile p
|
i9 : removeFile q
|
The empty string is interpreted as a reference to the current directory.
i10 : realpath ""
o10 = /tmp/M2-499257-0/76-rundir/
|
Caveat
Every component of the path must exist in the file system and be accessible to the user. Terminal slashes will be dropped. Warning: under most operating systems, the value returned is an absolute path (one starting at the root of the file system), but under Solaris, this system call may, in certain circumstances, return a relative path when given a relative path.