A completely-from-scratch hobby operating system: bootloader, kernel, drivers, C library, and userspace including a composited graphical UI, dynamic linker, syntax-highlighting text editor, network stack, etc.
This message is too verbose, yet it also misses critical information. A proper error message should include strerror() to indicate why fopen failed.
The getchar() pause also doesn't make much sense - the primary way a user would encounter this situation is by running the tool from a terminal, and there's no reason to pause after printing an error message there.
Going through all of the prompts and then finding that permissions are insufficient to edit the file is not great. The intent of this tool is to be run as root, and we could check for that up front with if (getuid() != 0) as a few other tools already do.
This tool is very low priority, and it has been my intent to replace it with a GUI for some time now.
There are a few problems with this:
strerror()
to indicate whyfopen
failed.getchar()
pause also doesn't make much sense - the primary way a user would encounter this situation is by running the tool from a terminal, and there's no reason to pause after printing an error message there.root
, and we could check for that up front withif (getuid() != 0)
as a few other tools already do.