Skip to content

⚖️  a portable, POSIX-compliant implementation of Bash’s `-ef` test, sharing a device and an inode value

License

Notifications You must be signed in to change notification settings

LucasLarson/samefile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

samefile

⚖️ a portable, POSIX-compliant implementation of Bash’s -ef test

AGPL latest release Super-Linter

Installation

L337

Make sure the executable named samefile in bin/ is either

  • moved into a directory in $PATH, or
  • added to $PATH.

Oh My Zsh

  1. clone the repostory:
git clone --depth 1 https://github.com/LucasLarson/samefile "${ZSH_CUSTOM:-${HOME}/.oh-my-zsh/custom}"/plugins/samefile
  1. Next, open the .zshrc file in your home directory
  2. insert the word samefile between the parentheses on the line that begins with plugins=.
  3. save and close the file, then source it with . "${HOME}"/.zshrc.

Usage

# 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

  1. the same exact file on
  2. the same exact machine and have
  3. 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.