mirror of
https://github.com/curl/curl.git
synced 2026-07-31 19:08:08 +03:00
tool: log when loading .curlrc in verbose mode
Inspired by @vszakats in https://github.com/curl/curl/pull/19631#issuecomment-3560803674 Closes #19663
This commit is contained in:
parent
2b0ca15c49
commit
fc09a2da4a
4 changed files with 19 additions and 4 deletions
|
|
@ -2225,7 +2225,7 @@ static ParameterError opt_file(struct OperationConfig *config,
|
||||||
err = PARAM_BAD_USE;
|
err = PARAM_BAD_USE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
err = parseconfig(nextarg, max_recursive);
|
err = parseconfig(nextarg, max_recursive, NULL);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case C_CRLFILE: /* --crlfile */
|
case C_CRLFILE: /* --crlfile */
|
||||||
|
|
|
||||||
|
|
@ -2227,6 +2227,8 @@ CURLcode operate(int argc, argv_item_t argv[])
|
||||||
{
|
{
|
||||||
CURLcode result = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
const char *first_arg;
|
const char *first_arg;
|
||||||
|
char *curlrc_path = NULL;
|
||||||
|
bool found_curlrc = FALSE;
|
||||||
|
|
||||||
first_arg = argc > 1 ? convert_tchar_to_UTF8(argv[1]) : NULL;
|
first_arg = argc > 1 ? convert_tchar_to_UTF8(argv[1]) : NULL;
|
||||||
|
|
||||||
|
|
@ -2240,7 +2242,8 @@ CURLcode operate(int argc, argv_item_t argv[])
|
||||||
if((argc == 1) ||
|
if((argc == 1) ||
|
||||||
(first_arg && strncmp(first_arg, "-q", 2) &&
|
(first_arg && strncmp(first_arg, "-q", 2) &&
|
||||||
strcmp(first_arg, "--disable"))) {
|
strcmp(first_arg, "--disable"))) {
|
||||||
parseconfig(NULL, CONFIG_MAX_LEVELS); /* ignore possible failure */
|
if(!parseconfig(NULL, CONFIG_MAX_LEVELS, &curlrc_path))
|
||||||
|
found_curlrc = TRUE;
|
||||||
|
|
||||||
/* If we had no arguments then make sure a URL was specified in .curlrc */
|
/* If we had no arguments then make sure a URL was specified in .curlrc */
|
||||||
if((argc < 2) && (!global->first->url_list)) {
|
if((argc < 2) && (!global->first->url_list)) {
|
||||||
|
|
@ -2254,6 +2257,11 @@ CURLcode operate(int argc, argv_item_t argv[])
|
||||||
if(!result) {
|
if(!result) {
|
||||||
/* Parse the command line arguments */
|
/* Parse the command line arguments */
|
||||||
ParameterError res = parse_args(argc, argv);
|
ParameterError res = parse_args(argc, argv);
|
||||||
|
if(found_curlrc) {
|
||||||
|
/* After parse_args so notef knows the verbosity */
|
||||||
|
notef("Read config file from '%s'", curlrc_path);
|
||||||
|
free(curlrc_path);
|
||||||
|
}
|
||||||
if(res) {
|
if(res) {
|
||||||
result = CURLE_OK;
|
result = CURLE_OK;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,8 @@ static int unslashquote(const char *line, struct dynbuf *param)
|
||||||
#define MAX_CONFIG_LINE_LENGTH (10*1024*1024)
|
#define MAX_CONFIG_LINE_LENGTH (10*1024*1024)
|
||||||
|
|
||||||
/* return 0 on everything-is-fine, and non-zero otherwise */
|
/* return 0 on everything-is-fine, and non-zero otherwise */
|
||||||
ParameterError parseconfig(const char *filename, int max_recursive)
|
ParameterError parseconfig(const char *filename, int max_recursive,
|
||||||
|
char **resolved)
|
||||||
{
|
{
|
||||||
FILE *file = NULL;
|
FILE *file = NULL;
|
||||||
bool usedarg = FALSE;
|
bool usedarg = FALSE;
|
||||||
|
|
@ -264,6 +265,11 @@ ParameterError parseconfig(const char *filename, int max_recursive)
|
||||||
if((err == PARAM_READ_ERROR) && filename)
|
if((err == PARAM_READ_ERROR) && filename)
|
||||||
errorf("cannot read config from '%s'", filename);
|
errorf("cannot read config from '%s'", filename);
|
||||||
|
|
||||||
|
if(!err && resolved) {
|
||||||
|
*resolved = strdup(filename);
|
||||||
|
if(!*resolved)
|
||||||
|
err = PARAM_NO_MEM;
|
||||||
|
}
|
||||||
free(pathalloc);
|
free(pathalloc);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,8 @@
|
||||||
|
|
||||||
/* only allow this many levels of recursive --config use */
|
/* only allow this many levels of recursive --config use */
|
||||||
#define CONFIG_MAX_LEVELS 5
|
#define CONFIG_MAX_LEVELS 5
|
||||||
ParameterError parseconfig(const char *filename, int max_recursive);
|
ParameterError parseconfig(const char *filename, int max_recursive,
|
||||||
|
char **resolved);
|
||||||
bool my_get_line(FILE *fp, struct dynbuf *db, bool *error);
|
bool my_get_line(FILE *fp, struct dynbuf *db, bool *error);
|
||||||
|
|
||||||
#endif /* HEADER_CURL_TOOL_PARSECFG_H */
|
#endif /* HEADER_CURL_TOOL_PARSECFG_H */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue