On Wed, Apr 21, 2021 at 6:36 AM Peng Yu <pengyu.ut@xxxxxxxxx> wrote: > > On Tue, Apr 20, 2021 at 11:31 PM Tadeus Prastowo > <tadeus.prastowo@xxxxxxxx> wrote: > > > > On Wed, Apr 21, 2021 at 6:27 AM Tadeus Prastowo > > <tadeus.prastowo@xxxxxxxx> wrote: > > > > > > On Wed, Apr 21, 2021 at 6:20 AM Peng Yu via Gcc-help > > > <gcc-help@xxxxxxxxxxx> wrote: > > > > > > > > It seems when -print-prog-name does not exist. gcc still returns > > > > normally. This doesn't make much sense. Shouldn't it return a nonzero > > > > exist status in such a case? Thanks. > > > > > > > > $ gcc -print-prog-name=blahblah; echo $? > > > > blahblah > > > > 0 > > > > > > It returns normally because the option is provided as a service to > > > find out about the absolute path of a possibly-hypothetical library, > > > which is useful when you intend to build that library. > > > > That is for -print-file-name [1]. But the rationale applies to > > -print-prog-name. The absolute path is also useful to build/search > > something relative to where the given program name is expected by GCC > > to exist. > > > > [1] https://gcc.gnu.org/onlinedocs/gcc/Developer-Options.html#Developer-Options > > The problem is when the prog-name is not found. It should have > returned such error info. It is a surprise that gcc is silent about > this error. Therefore, it doesn't make sense. Sometimes, such as when building your own GCC, you know that prog-name does not exist yet. If the service provided by the option returns an error code, the build will fail. In that case, you would think that it would make sense for the option to return a success. In the case where you expect prog-name to exist, you simply use another command to test for the presence of the prog-name (e.g., the Bash shell's [ -x `gcc -print-prog-name=blahblah` ]). > -- > Regards, > Peng -- Best regards, Tadeus