Artificial intelligent assistant

How do idiomatic Unix programs detect what prefix they are installed under? If I install a binary with non-standard prefix, e.g. `/opt/bin/foo`, which needs some static files from `/opt/share/foo`, how does it find them? Using back references relative to the executable (`../share/foo`)? Hardcoded at compile time? What's the _idiomatic_ way for an application to handle variable installation prefix? Should all directories be prefixed? (what about `/var`?)

It's common to hard-code such references at compile time, and perhaps provide a command line option or environment variable to override the compile-time default. Often the program just remembers the location of one configuration file (typically under `/etc`) where any compile-time defaults can be overridden. This approach makes most sense for open source software that is compiled by the same people that make the operating system, as part of a Linux distribution or BSD ports.

For applications distributed in a binary form, the usual approach is to locate the application binary from its zeroth argument. By convention, the zeroth argument to `execve` (i.e. `argv[0]`) is the path to the binary (it's up to the caller, often a shell, to respect the convention). If `argv[0]` doesn't contain any `/`, the application should perform `$PATH` lookup on it.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 06aa7fe4189f03af0d35de36c3f276f5