basherpm/basher

link-bins mistakenly finds package itself as bin under certain conditions

pawamoy opened this issue · 0 comments

...which were too long for the title and are the following:

  • when package was linked with basher link
  • when no BINS are specified in package.sh
  • when no bin directory exists

When all these conditions meet, then basher tries to find all files in the root of the packages that have exec perm and are either a regular file or a symlink. It thus catches the directory name itself, creates a dangling symlink in cellar/bin, and attempt to chmod +x this symlink (and this is were it finally fails).

The culprit:

bins=($(find "$BASHER_PACKAGES_PATH/$package" -maxdepth 1 -perm -u+x -type f -or -type l))

Thankfully, it is easily solved with the -mindepth levels option of find:

Do not apply any tests or actions at levels less than levels (a non-negative integer). -mindepth 1 means process all files except the starting-points.

- bins=($(find "$BASHER_PACKAGES_PATH/$package" -maxdepth 1 -perm -u+x -type f -or -type l))
+ bins=($(find "$BASHER_PACKAGES_PATH/$package" -maxdepth 1 -mindepth 1 -perm -u+x -type f -or -type l))