On Sat, Oct 12, 2024 at 21:43:39 -0400, I mistakenly wrote: > See the ":" followed by two spaces? Unlike systemctl, well-behaved > programs set "errno" when they puke, and that setting is turned into > a more-or-less useful error message like "Permission denied". > "$!" would have held that message.
>> On Sat 12 Oct 2024 at 22:23:31 (-0400), Greg Wooledge replied: > I don't think this is correct. A *function* can set errno (a global > variable in C), in addition to returning a value. A process can't, > unless there has been some major change to the Unix process model that > I've missed. You're right, keyboard in motion before brain in gear. Since I don't have systemctl installed, the system() *function* failed when it tried to exec a non-existent program and correctly set "$!" to "No such file or directory". If I call 'system("/bin/mkdir", "/etc/something")' as myself, the /bin/mkdir *process* handles errno and prints "Permission denied". All system() sees is a non-0 exit code. Removing the --quiet flag and using something like safesys() would: * let systemctl write something (hopefully an error message), * show exactly what arguments are being passed to it, and * show its exit value. -- Karl Vogel I don't speak for anyone but myself In [the movie] "Seven", I put it in my contract: The wife's head stays in the box. --Brad Pitt on early contract negotiations