Skip to content

Conversation

@per1234
Copy link
Contributor

@per1234 per1234 commented Sep 16, 2025

Paths in some workflows and tasks are configured via variables. Previously, when a value specified a folder path, a trailing slash was added. The intent behind this was to make it slightly more clear that the value was referring to a folder (e.g., ./ vs. .). However, this practice can be harmful in the case where the value is used as a base component in a path, as then it is most appropriate to omit the path separator in the concatenation code, which is at all clear (e.g., FOO_PATH: foo/, {{.FOO_PATH}}bar -> foo/bar). And if the separator is used in the concatenation
code, it results in a confusing double separator in the resulting path (e.g., FOO_PATH: foo/, {{.FOO_PATH}}/bar ->
foo//bar). The benefit of the trailing slash on the variable definition is miniscule at most, since the variable name, documentation, and other context should make it obvious that the value is a folder path. So the harm of this approach outweighs the benefit.

For this reason, it is better to omit the trailing slash in the variable definition (e.g., FOO_PATH: foo, {{.FOO_PATH}}/bar -> foo/bar). Even though this approach is not relevant in cases where the path is not used as a base component, it is best to be consistent in this practice.

Paths in some workflows and tasks are configured via variables. Previously, when a value specified a folder path, a
trailing slash was added. The intent behind this was to make it slightly more clear that the value was referring to a
folder (e.g., `./` vs. `.`). However, this practice can be harmful in the case where the value is used as a base
component in a path, as then it is most appropriate to omit the path separator in the concatenation code, which is at
all clear (e.g., `FOO_PATH: foo/`, `{{.FOO_PATH}}bar` -> `foo/bar`). And if the separator is used in the concatenation
code, it results in a confusing double separator in the resulting path (e.g., `FOO_PATH: foo/`, `{{.FOO_PATH}}/bar` ->
`foo//bar`). The benefit of the trailing slash on the variable definition is miniscule at most, since the variable name,
documentation, and other context should make it obvious that the value is a folder path. So the harm of this approach
outweighs the benefit.

For this reason, it is better to omit the trailing slash in the variable definition (e.g., `FOO_PATH: foo`,
`{{.FOO_PATH}}/bar` -> `foo/bar`). Even though this approach is not relevant in cases where the path is not used as a
base component, it is best to be consistent in this practice.
@per1234 per1234 self-assigned this Sep 16, 2025
@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Sep 16, 2025
@per1234 per1234 merged commit 380bcc0 into arduino:main Sep 16, 2025
53 checks passed
@per1234 per1234 deleted the slash branch September 16, 2025 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic: code Related to content of the project itself type: enhancement Proposed improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant