Search code examples
linuxbashld-preloadrlwrap

LD_PRELOAD in rlwrap?


When I do something in my script like

rlwrap -f words.txt LD_PRELOAD=mylib.so command "$@" 

I always get something like

rlwrap: error: cannot execute LD_PRELOAD=mylib.so no such file or directory 

Even though that file totally exists and removing rlwrap would work just fine.

How do I put LD_PRELOAD in rlwrap? basically I want to make mylib.so apply to my 'command' only.

I did try putting LD_PRELOAD=mylib.so in from of rlwrap, it runs, but LD_PRELOAD didn't apply to command as I wished.


Solution

  • You can wrap the command in a shell:

    rlwrap -f words.txt bash -c 'LD_PRELOAD=mylib.so command "$@"' - "$@"