Skip to content

Conversation

@SleepyBag
Copy link

@SleepyBag SleepyBag commented Nov 25, 2019

In-string references will be supported now then.
Specifically, config parser will dereference all references shown in a field. Besides, if there are nested references, it will dereference them recursively until there is no "${}" left.

Though this cause some uncompatibility. If someone wrote "${}" in a 'exec' script, config parser will try to dereference it. One has to add another '$' before "${}" to get avoid of this. That is, one should use "$${}" if he wants to use "${" without being dereferenced.

This commit is experiment with the following config file:

[A]
a1 = a1
a2 = a2
a3 = a3
a4 = a4

[B]
b1 = ${A.a1}
b2 = b2${A.a2}
b3 = ${A.a3}b3
b4 = b4${A.a4}b4

[C]
c1 = ${B.b1}
c2 = c2${B.b2}
c3 = ${B.b3}c3
c4 = c4${B.b4}c4

[bar/bar]
a1 = ${A.a1}
a2 = ${A.a2}
a3 = ${A.a3}
a4 = ${A.a4}

b1 = ${B.b1}
b2 = ${B.b2}
b3 = ${B.b3}
b4 = ${B.b4}

c1 = ${C.c1}
c2 = ${C.c2}
c3 = ${C.c3}
c4 = ${C.c4}

d1 = d1${C.c1}${C.c1}
d2 = ${C.c2}${C.c2}d2
d3 = d3${C.c3}d3${C.c3}
d4 = ${C.c4}${C.c4}d4

e1 = ${A.${A.${A.a1}}}
e2 = e2${A.${A.a2}}

f1 = $$f1
f2 = $$${C.c2}
f3 = $${C.c3}

Maintainer EDIT:

Fixes #954

@codecov
Copy link

codecov bot commented Nov 25, 2019

Codecov Report

❌ Patch coverage is 0% with 44 lines in your changes missing coverage. Please review.
✅ Project coverage is 9.26%. Comparing base (e5783d4) to head (09b4dfd).
⚠️ Report is 743 commits behind head on master.

Files with missing lines Patch % Lines
include/components/config.hpp 0.00% 44 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           master   #1938      +/-   ##
=========================================
- Coverage    9.29%   9.26%   -0.03%     
=========================================
  Files         180     180              
  Lines       10816   10846      +30     
=========================================
  Hits         1005    1005              
- Misses       9811    9841      +30     
Flag Coverage Δ
unittests 9.26% <0.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@patrick96
Copy link
Member

Oh wow, this is awesome! This would make the config a lot more expressive.

Thanks a lot!
Will take a look at this later.

@patrick96
Copy link
Member

Sorry for never getting to this.

I had some reservations about this and thought I would address them once I got around to working on the config parser again, but that never happened.

The goal with the config parser is to not resolve variables when looking up config values, but actually when parsing the config file. This would also allow us to fix the infinite recursion issue (#783). The nested references would make such an endeavor quite difficult, and I don't think polybar needs nested references.

We also just recently decided to make the backslash the escape character in config values.

As for next steps, I of course don't expect you to still work on this, it has been quite some time. But if you still want to, let me know. Doing references inside the config parser is not feasible right now, because it does require quite a few architectural changes. But I think we can just keep recursively resolving references for now until we get that functionality into the config parser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mixed References And Text in Config Values

2 participants