tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: rmdir -p



>> [darcy%dilbert.druid.net@localhost:/usr/NetBSD/cvs/pkgsrc/graphics/librsvg] $
>> pkglint WARN: Makefile:38: The use of a leading "-" to suppress errors
>> is deprecated. 0 errors and 1 warnings found.
> It is better to express that explicitly via || true.

A leading - was added to make specifically to express the semantics of
"ignore errors from this command".  || says "do this, and then, if it
fails, do that".  That using it with an always-successful command as
the RHS has the effect of ignoring failures from the LHS is a side
effect of its primary purpose, via a comparatively little-known aspect
of its definition - that the exit status of the || construct is the
exit status of the last-executed command.

Thus, I would say that the "leading -" way is the explicit way to
suppress errors and the "|| true" way is a kludge based on a side
effect of a syntax designed for a different purpose.

Furthermore, leading - works regardless of shell, and does not force
make to shell the command if it doesn't contain metasyntax; || true
depends on the shell make uses using sh rules for ||, and does force
make to run a shell.  (Not that either one is likely to matter much in
practice.)

/~\ The ASCII                           der Mouse
\ / Ribbon Campaign
 X  Against HTML               mouse%rodents.montreal.qc.ca@localhost
/ \ Email!           7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Home | Main Index | Thread Index | Old Index