⚖️ a portable, POSIX-compliant implementation of Bash’s -ef
test
Make sure the executable named
samefile
in
bin/
is either
- moved into a directory in
$PATH
, or - added to
$PATH
.
- clone the repostory:
git clone --depth 1 https://github.com/LucasLarson/samefile "${ZSH_CUSTOM:-${HOME}/.oh-my-zsh/custom}"/plugins/samefile
- Next, open the
.zshrc
file in your home directory - insert the word
samefile
between the parentheses on the line that begins withplugins=
. - save and close the file, then
source
it with. "${HOME}"/.zshrc
.
# not this
[ path/to/some/file -ef path/to/another/file ]
# and definitely not this
[[ path/to/some/file -ef path/to/another/file ]]
# but rather this
samefile path/to/some/file path/to/another/file
# or this
samefile --verbose path/to/some/file path/to/another/file
# or this
samefile -v path/to/some/file path/to/another/file
# returns a `0` exit status on success and `1` for failure
# just like `[`, `[[`, and `test`
Bash’s -ef
and samefile
both check that two files aren’t just similar, but
are
- the same exact file on
- the same exact machine and have
- the same exact inode values.
But only samefile
properly runs on a maximally portable POSIX-conformant
interpreter where stat
is also installed. samefile
works just fine in Bash
environments, too.