Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ test-driven methodologies, and modern toolchains for unrivaled success.
* Preserved custom formatting, comments, and settings in ``.vscode/extensions.json`` during project IDE initialization instead of unconditionally overwriting the file (`issue #5473 <https://github.com/platformio/platformio-core/issues/5473>`_)
* Fixed path parsing in `pio ci <https://docs.platformio.org/en/latest/core/userguide/cmd_ci.html>`__ on Windows by using OS-native path separators for the ``PLATFORMIO_CI_SRC`` environment variable (`pull #5514 <https://github.com/platformio/platformio-core/pull/5514>`_)
* Fixed an issue where undefine flags with spaces (e.g., ``-U MACRO``) in ``build_flags`` were parsed incorrectly, passing only a bare ``-U`` to the compiler (`issue #5237 <https://github.com/platformio/platformio-core/issues/5237>`_)
* Fixed an issue where a legacy ``$PROJECT_HASH`` variable at the start of an option value was not expanded when the value also ended with a ``$`` character (`issue #5520 <https://github.com/platformio/platformio-core/issues/5520>`_)

6.2.0 (2026-09-05)
~~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion platformio/project/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def _expand_interpolations(self, section, option, value):
stop = True
for name in legacy_vars:
x = value.find(f"${name}")
if x < 0 or value[x - 1] == "$":
if x < 0 or (x > 0 and value[x - 1] == "$"):
continue
value = "%s${%s}%s" % (value[:x], name, value[x + len(name) + 1 :])
stop = False
Expand Down
17 changes: 17 additions & 0 deletions tests/project/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,23 @@ def test_nested_interpolation(tmp_path: Path):
assert testing_command[5] == '${UPLOAD_PORT and "-p "+UPLOAD_PORT}'


def test_legacy_variable_at_value_start(tmp_path: Path):
# A legacy (brace-less) $PROJECT_HASH at the start of a value must be expanded
# even when the value ends with "$". The escaped-variable guard used to read the
# last character (value[-1]) for a match at index 0 and wrongly skip expansion.
project_conf = tmp_path / "platformio.ini"
project_conf.write_text("""
[env:myenv]
build_flags = $PROJECT_HASH-$
""")
with fs.cd(str(tmp_path)):
config = ProjectConfig(str(project_conf))
value = config.get("env:myenv", "build_flags")[0]
assert "$PROJECT_HASH" not in value
assert value.startswith(os.path.basename(str(tmp_path)) + "-")
assert value.endswith("-$")


def test_extends_order(tmp_path: Path):
project_conf = tmp_path / "platformio.ini"
project_conf.write_text("""
Expand Down