Skip to content

WIP: New config hierarchy

Gabriel Lisaca requested to merge Hoboneer/Surfraw:new-config-hierarchy into master

Change config file hierarchy and read order

Previously, the hierarchy was:

  1. Local config
  2. w3_config_hook
  3. Global config

While in the read order, 3 and 1 were swapped. This made for some annoyances when using surfraw in scripts.

Now, the hierarchy is as follows:

  1. Pre-existing environment variables
  2. Local config
  3. w3_config_hook
  4. Global config

The read order is the same as the hierarchy and code should use the def* family of functions instead of setting variables directly.

Now calls like the following can work:

$ export SURFRAW_graphical=yes
$ surfraw foo bar
$ surfraw foo baz

Which will open both calls in the graphical browser.

This would propagate to scripts that call surfraw, thus making their use easier as no environment variables like SURFRAW_FLAGS have to be introduced and supported in every script.

There have been attempts at backwards compatibility. New-style (i.e. files named "config") take precedence, but fall back on the old behaviour ("conf") if not present.

Merge request reports