-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add daemon option to avoid making BaseDir #2422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @nwf,
thank you very much for opening this PR! I think the feature is sane, I'd just like the boolean to be inverted for easier reading of the source; details inline.
Thanks and best regards,
—octo
P.S.: I'd even be open to make erroring out the default and make -B
enable the mkdir
behavior. @rubenk, any thoughts?
@@ -158,7 +158,7 @@ static int init_global_variables(void) { | |||
return 0; | |||
} /* int init_global_variables */ | |||
|
|||
static int change_basedir(const char *orig_dir) { | |||
static int change_basedir(const char *orig_dir, int nocreate) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use a positive logic here, "not nocreate" is a double negation and hard to read and I'd much prefer a create
boolean.
Also, please use _Bool
instead of int
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both done.
sstrerror(errno, errbuf, sizeof(errbuf))); | ||
free(dir); | ||
return -1; | ||
if (nocreate == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tries the chdir()
call a second time, which is not elegant. How about we extend the above logic to:
else if (!create || (errno != ENOENT)) {
// ^^^^^^^^^^
/* report error, return */
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's better, I agree.
One possible implementation of #2421
Thanks @nwf! |
One possible implementation of #2421