Skip to content

Commit

Permalink
Merge branch 'fix-envvar-precedence' of https://github.com/sotpapathe…
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Sep 11, 2024
2 parents 236b33c + 1e15a0c commit 985af17
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ncmpc 0.50 - not yet released
* lyrics/musixmatch: add new lyrics extension
* lyrics/google: fix partial loading of lyrics
* support MPD 0.22 tag "label" (requires libmpdclient 2.17)
* fix config file overriding MPD_HOST environment variable

ncmpc 0.49 - (2023-08-04)
* fix UI freeze if lyrics plugin is stuck
Expand Down
3 changes: 3 additions & 0 deletions src/Main.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ try {
GetGlobalKeyBindings().Check(nullptr, 0);
#endif

/* set options from environment variables */
options_env();

/* parse command line options - 2 pass */
options_parse(argc, argv);

Expand Down
6 changes: 5 additions & 1 deletion src/Options.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,11 @@ options_parse(int argc, const char *argv[])
handle_option(opt->shortopt, nullptr);
else if (opt && opt->argument)
option_error(ERROR_MISSING_ARGUMENT, opt->longopt, opt->argument);
}

if (options.host.empty() && getenv("MPD_HOST"))
void
options_env()
{
if (getenv("MPD_HOST"))
options.host = getenv("MPD_HOST");
}
2 changes: 2 additions & 0 deletions src/Options.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,5 @@ struct Options {
extern Options options;

void options_parse(int argc, const char **argv);

void options_env();

0 comments on commit 985af17

Please sign in to comment.