@@ -18,7 +18,12 @@ on some earlier verions of macOS.
1818## Installation
1919
2020Download the [ latest release] ( https://github.com/heckman/macOS-alias-utils/releases/latest )
21- and put the two universal binaries somewhere on your ` PATH ` .
21+ and put the two universal binaries in ` bin ` somewhere on your ` PATH ` .
22+
23+ The scripts in ` scripts ` can be installed the same way,
24+ or, if using the ` Zsh ` shell, they can be used as autoloadable functions
25+ by putting them somewhere on the ` fpath ` .
26+ (This is how I use them.)
2227
2328Alternatively, build the binaries from source.
2429You will neet to have Command Line Tools (CLT) installed,
@@ -29,48 +34,106 @@ From there, run `./build`.
2934This should produce the ` readalias ` and ` mkalias ` binaries
3035in a ` ./bin ` directory.
3136
32- ## Features
33-
34- At the moment, ` readalias ` simply prints the path to the original item
35- and has no options beyond ` --help ` and ` --version ` ,
36- while ` mkalias ` can be given the ` force ` ( or ` -f ` ) option
37- indicating existing files should be overwritten--by default it
38- is non-destructive.
37+ ## Usage
3938
40- Both respond appropriately to ` --version ` and ` --help ` options.
39+ Both binaries respond appropriately to ` --version ` and ` --help ` options.
4140The help output includes descriptions their various exit codes.
4241
43- ### Future features
42+ The help text is also easy to find in their source code.
43+
44+ ### readalias
45+
46+ Prints the path to the original file of an alias file.
47+ It takes no options, and has one required argument:
48+
49+ ` readalias <alias-file> `
50+
51+ On error, nothing is printed to stdout,
52+ an error message is printed to stderr,
53+ and the exit status is non-zero.
54+
55+ ### mkalias
56+
57+ Creates an alias file that points to the path of an original.
58+ It takes two required positional arguments, and one optional
59+ flag, which will cause ` <alia-file> ` to overwrite any existing file.
60+ Be default, the command will fail if the file already exists.
61+
62+ ` mkalias [-f|--force] [--] <path-of-original> <alias-file> `
63+
64+ Never writes to stdout.
65+ On error, an message is printed to stderr,
66+ and the exit status is non-zero.
67+
68+ ## Scripts
4469
45- By default ` mkalias ` will fail
46- rather than overwrite and existing file.
47- The ` force ` (or ` -f ` ) option will cause existing
48- files to be clobbbered, although a directory
49- will still not be overwritten.
70+ These scripts make use of the ` readalias ` and ` mkalias ` binaries.
71+ The funcionality provided by these scripts
72+ may eventually be merged into the binaries,
73+ or be made into new binaries themselves.
74+ The format of these scripts is such that
75+ the files can be used as autoloadable functions in Zsh
76+ by simply placeing them in a directory on the ` fpath ` .
77+ This is how I use them, which is why each script
78+ is a single function called from its body, and why
79+ the two helper functions have their own scripts.
5080
51- I indend to offer a third behaviour, which,
52- when the specified name for the alias is taken,
53- generates a new name in the way the Finder does.
54- This might become the default behaviour
55- in which case we will need a new a command-line option
56- for the fail-on-existing file behaviour.
81+ ### isalias
5782
58- The renaming strategy is this: Use the same name as the original,
59- if avaialbe, otherwise append ` alias ` to the name. If that
60- is still not unique, then append the smallest integer
61- greater than one, separated by a space, sufficient to
62- generate a unique name.
83+ This wraps the ` readalias ` binary, and produces no output.
84+ It produces a successful exit status (0) if the file provided
85+ is an alias file, even if it is broken. It returns a non-zero
86+ exit status otherwise.
6387
64- ### Edge Cases
88+ ### makealias
89+
90+ This forwards all arguments passed to it to the ` mkalias ` binary,
91+ along with one additional argument: a name generated
92+ using ` namealias ` , so ` <alias-file> ` can be unspecified,
93+ in which case a suitable name will be generated.
94+
95+ ### namealias
96+
97+ This is a helper used by ` makealias ` .
98+ Given a path, this will print a name
99+ suitable to be used for an alias file,
100+ using the the same naming strategy used by the Finder.
101+
102+ ### nextname
103+
104+ This is a helper used by ` namealias ` .
105+ It prints a path that is guaranteed (at the moment) not to exist.
106+ It takes the desired path as its only argument.
107+ It prints the path if it does not exist, otherwise
108+ it prints the path appended with a space and number, at least 2,
109+ an only large enough to make the path unique.
110+
111+ ## Issues
112+
113+ ### Undetermined behaviour
65114
66115These utilites have only been nominally tested,
67- and most edge cases have not been explored:
116+ and some edge cases have not been explored:
68117
69118- Broken Aliases
70119- Aliases to unmounted external/network volumes
71- - Creating and Alias to another Alias
72120
73- ## Props where due
121+ ### Known edge cases
122+
123+ - Creating an Alias to another Alias file makes a new
124+ Alias pointing to the original of the other Alias.
125+ This is the expected behaviour.
126+ - Arguments that are empty strings will be treated
127+ as ` . ` , which produces potentially confusing
128+ error messages such as "Error: directory exists:".
129+
130+ ## Roadmap
131+
132+ - Incorporate scripts into binaries
133+ - Generate an explicit error when arguments are empty
134+ - Add formal testing
135+
136+ ## Acknowledgements
74137
75138Prior to writing these two utilites,
76139I was using _ alisma_ , by Howard Oakley,
0 commit comments