github.com/charlievieth/fastwalk@v1.0.3/scripts/links2getdirentries.bash (about)

     1  #!/usr/bin/env bash
     2  
     3  # This script checks if a binary program (EXE) compiled for
     4  # Darwin (macOS) links to __getdirentries64.
     5  
     6  if [[ -t 2 ]]; then
     7      ERROR=$'\E[00;31m'error$'\E[0m'
     8  else
     9      ERROR=error
    10  fi
    11  
    12  [[ ! -r "$1" ]] && {
    13      echo -e >&2 "${ERROR} invalid argument EXE: no such file or directory: $1"
    14      echo >&2 "usage: $0 EXE"
    15      exit 1
    16  }
    17  [[ "$(uname -s)" != Darwin ]] && {
    18      echo -e >&2 "${ERROR} invalid OS: $(uname -s)"
    19      echo >&2 ''
    20      echo >&2 "This script is only supported on and to applicable to Darwin (macOS)."
    21      exit 2
    22  }
    23  ! otool -dyld_info "$1" | \grep -qF getdirentries64 || {
    24      echo -e >&2 "${ERROR} executable links to __getdirentries64: $1"
    25      echo >&2 ''
    26      echo >&2 'To not link to __getdirentries64 use the "nogetdirentries" build tag:'
    27      echo >&2 '  $ go build -tags nogetdirentries <YOUR_EXE>'
    28      exit 2
    29  }