macosbashdyliblibreadline

"libreadline" bugs getting in the way of bash scripts?


I was trying to convert a bash script to binary using shc. I put in a colored help page like this:

#!/bin/bash
if [ "$1" = "--help" ]; then
    echo -e "\e[0;31m———————————————\e[0m"
    echo -e "\e[0;33m  Script help \e[0m"
    echo -e "\e[0;31m———————————————\e[0m"
    echo -e "\e[0;34mOPTIONS\e[0m"
    echo -e "\e[1;33m--help\e[0m"
    echo -n "   "
    echo -e "\e[0;33mAccess this help page.\e[0m"
    echo -e "\e[0;31m———————————————\e[0m"
    exit 0
fi

When I tested it normally, it was working fine all the time. But then I converted it to binary with shc -T -f script, and now every other time I run ./script.x --help it gives me this error message:

dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib
  Referenced from: /bin/bash
  Reason: no suitable image found.  Did find:
    /usr/local/opt/readline/lib/libreadline.6.dylib: open() failed with errno=24
Trace/BPT trap: 5

What happened?


Solution

  • Alright, so if anyone else is reading this with the same problem, I found a solution:
    sysctl -w kern.maxfiles=65000
    It's apparently an alternative of ulimit -n that OS X allows. But it's still a mystery as to why it's necessary in the first place...