ADR-0018: Spaces in File Names Are Not Allowed
Status: | ACCEPTED |
Date: | 2022-09-20 |
Author(s): | Sven Strittmatter sven.strittmatter@iteratec.com |
Context
We have the issue that most of our make targets fail, if this repository working copy is cloned into a file location which contains white spaces in its file path.
We chose make as build tool because of its maturity and capabilities, but it lacks one essential feature: Handling of white spaces in paths. Of course, it is possible to escape paths, but this has only an effect to paths passed as string to a make target's command which will be evaluated by the shell. Make itself ignores such escaping which leads to bugs especially in constructs such as:
@for chart in $(HOOKS_CHART_LIST); do \
$(BIN_DIR)/generate-helm-docs.sh --hook $${chart} $(HELM_DOCS_DIR); \
done
Problem
The for-construct of shell does word splitting on any whitespace, not only newline. We assume lists of directories delimited by newlines. We heavily rely on looping subdirectories with such loops to build our modules (scanners, hooks etc.). Using a different sentinel character (e.g. :
) is not a possible fix because setting IFS
in the Makefile
has no effect on word splitting, even for while-read loops.
Solutions
- To fix this we need to extract all of these loop constructs into shell scripts (like
bin/npm-ci-all.sh
for thenpm-ci-all
target). That's lot of work and counteracts the sense of make. - Use another build tool which can deal with this will also result in a lot of work. We just did this to use make. Luckily we cleaned up lot of things, so this may take less effort than the migration to make.
- Simply forbid white spaces in file names.
Decision
We decided to simply forbid white spaces in file paths. If one clones the repository to a location with white spaces in the path we exit make with an error message.
Consequences
- We must not use white spaces for filenames in our repository.
- Windows users will possibly have a slightly worse user experience.
- Someone who can't freely modify or change the target path for his working copy can't make the secureCodeBox.