-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
curl: add command line option to prohibit overwriting files #4439
Conversation
This adds the parameter '--override' and '--no-override'. If '--no-override' is set, file eutputs will fail if the file already exists. '--override' will change nothing.
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.
Thanks!
To complete the work and have it "mergable", you also need to add documentation (see docs/cmdline-opts
) and at least one test case that verifies it.
The CI failure is test 1139 which fails because the lack of docs for the flag. |
On Sat, Sep 28, 2019 at 10:08:12PM -0700, Emil Engler wrote:
This adds the parameter '--override' and '--no-override'.
IMHO --overwrite and --no-overwrite are more descriptive.
|
@bagder What do you mean by lack of docs? |
Oops, my mistake! |
@dfandrich 'override' is much more common.
|
The cases where "override" is used, the sense of the meaning is "override". In
the cases where "overwrite" is used, the sense of the meaning is "overwrite".
They are not synonyms. When overwriting a file, "overwrite" is the more correct
term.
|
I'm with @dfandrich. |
@@ -42,6 +42,9 @@ | |||
#include "tool_parsecfg.h" | |||
#include "tool_main.h" | |||
|
|||
/* to use access() */ | |||
#include <unistd.h> | |||
|
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.
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
The scan-build also warns:
|
docs/cmdline-opts/override.d
Outdated
Help: Permit/Prohibit overwriting of files | ||
--- | ||
If you route the output to a file which already exists, it can be disabled using | ||
--no-override. The --override argument is the default. |
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.
Can I suggest a clearer wording that focuses on the use and the effects? Maybe something like this:
"This option allows curl to overwrite already existing files with the output options. If --no-overwrite is used, curl will instead return an error (which?) rather than overwriting an existing file. The default is to allow overwrites."
@jzakrzewski Ok, I will change this to overwrite. |
@emilengler you can change the title yourself, right? |
Windows build failures:
|
@bagder No, only people with write access can change the title of a PR. |
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.
Generally I'm not a fan of the way this was implemented, and does it serve a purpose to do prohibit overwriting a header filename or trace filename etc?
src/tool_getparam.c
Outdated
#ifndef HAVE_UNISTD_H | ||
static bool CheckFile(char *fname, bool overwrite_file_prohibit) | ||
{ | ||
/* Make this function useless if unistd is not available */ | ||
printf("overwrite parameter is being ignored because unistd.h is missing\n"); | ||
return TRUE; | ||
} | ||
#endif | ||
|
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.
we can't do printfs from these functions, it would need a warnf global I think. but a better idea is use stat
or something else when access
is not available
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.
stat still needs unistd.h I think
Push |
I still don't like this idea, I think it is unnecessary to make it part of curl. It is easy enough in script to see if a file exists. In batch there's |
Will close this because of inactivity. |
About
This adds the parameter '--override' and '--no-override'.
If '--no-override' is set, file eutputs will fail if the file
already exists.
'--override' will change nothing.
Testing (Unix)
This happens in the root git directory.
Please adjust it to your system/config.
This will result in
P.S: This is my first PR to this project so please correct me if I did some mistakes :)