You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-6
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,10 @@ Most of this module's functions also return absolute, well-formed paths: that is
10
10
11
11
(**Note:** unlike their operating system counterparts, these functions do *not* accept multiple arguments (except for `realpath.join`), and do *not* take option parameters. Do not pass `--` to them or expect to get multiple results for multiple arguments!)
12
12
13
+
### Installation And Use
14
+
15
+
Copy and paste the code into your script, or place it on `PATH` and `source "$(command -v realpaths)"`. You can install it on your `PATH` with [basher](https://github.com/basherpm/basher), using `basher install bashup/realpaths`. The code is licensed CC0, so you are not required to add any attribution or copyright notices to your project.
16
+
13
17
### Resolving Symlinks
14
18
15
19
#### realpath.location
@@ -36,19 +40,27 @@ Arguments to the left of an absolute path argument are discarded (similar to Pyt
36
40
37
41
All path components are resolved *logically* rather than physically: that is to say, `..` is processed by removing elements from the path string rather than by inspecting the filesystem. (So symlinks are not processed in any way, and the existence or accessibility of the files and directories is irrelevant.)
38
42
39
-
#### realpath.dirname*path*
43
+
#### realpath.dirname
40
44
41
-
Sets `REPLY` to the directory name of *path*, always returning success. Produces the *exact* same results as `REPLY=$(dirname -- "$1")` except much, *much* faster. Always succeeds.
45
+
Sets `REPLY` to the directory name of `$1`, always returning success. Produces the *exact* same results as `REPLY=$(dirname -- "$1")` except much, *much* faster. Always succeeds.
42
46
43
-
#### realpath.basename*path*
47
+
#### realpath.basename
44
48
45
-
Sets `REPLY` to the basename of *path*. Produces the *exact* same results as `REPLY=$(basename -- "$1")` except much, *much* faster.
49
+
Sets `REPLY` to the basename of `$1`. Produces the *exact* same results as `REPLY=$(basename -- "$1")` except much, *much* faster.
46
50
47
51
### Determinining Canonical Paths
48
52
49
-
#### realpath.canonical*path*
53
+
#### realpath.canonical
50
54
51
-
Sets `REPLY` to the *fully canonicalized* form of path, resolving symlinks in every part of the path where that can be done, roughly equivalent to `realpath -m` or `readlink -m`. Always succeeds, but potentially quite slow, depending on how many directories are symlinks.
55
+
Sets `REPLY` to the *fully canonicalized* form of `$1`, resolving symlinks in every part of the path where that can be done, roughly equivalent to `realpath -m` or `readlink -m`. Always succeeds, but potentially quite slow, depending on how many directories are symlinks.
52
56
53
57
You don't really need this function unless you are trying to determine whether divergent paths lead to the "same" file: for use cases that don't involve comparing paths, `realpath.absolute` should be sufficient. (Note, too, that using canonical paths can result in user confusion, since they have to reconcile their inputs with your outputs.)
To the extent possible under law, <arel="dct:publisher"href="https://github.com/pjeby"><spanproperty="dct:title">PJ Eby</span></a>
64
+
has waived all copyright and related or neighboring rights to <spanproperty="dct:title">bashup/realpaths</span>.
65
+
This work is published from: <spanproperty="vcard:Country"datatype="dct:ISO3166"content="US"about="https://github.com/bashup/realpaths">United States</span>.
0 commit comments