Skip to content

Conversation

@AnyOldName3
Copy link

@AnyOldName3 AnyOldName3 commented Nov 19, 2025

This might not work on MacOS, but is fine on Linux and Windows.

Otherwise, #1084 happens, and building the library after cloning it to a path like C:\C++Libraries\KTX-Software doesn't work.

If realpath isn't available on MacOS, then I guess $(pwd) could be run through a sed script that regex-escaped it, but there are still some edge cases that that wouldn't handle well. e.g. with symlinks.

Fixes #1084.

This might not work on MacOS, but is fine on Linux and Windows.
@CLAassistant
Copy link

CLAassistant commented Nov 19, 2025

CLA assistant check
All committers have signed the CLA.

@MarkCallow
Copy link
Collaborator

realpath is available on macOS.

done
else
if [[ $workdir =~ $(pwd)(/(.*$)?)? ]]; then
relative_path=$(realpath --relative-base=$(pwd) -- $workdir)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macos's realpath does not take any options except -q to silence warnings. This is the reason for the CI build failure.

Please find an alternative way, at least for macOS.

@MarkCallow
Copy link
Collaborator

Otherwise, #1084 happens, and building the library after cloning it to a path like C:\C++Libraries\KTX-Software doesn't work.

Do you see paths with '' path separators in git bash or bash running under WSL on Windows?

Wouldn't it be easier to update the RE to allow either type of path separator?

@AnyOldName3
Copy link
Author

In this case it's nothing to do with the path separator - it's a Unixy cygpath-style path here when running on Windows, so only has forward slashes. The problem is that there are plenty of other characters that are legal in paths that are interpreted differently in a regex. On my machine, it's that I had two consecutive + characters making it an invalid regex, but there are other obvious examples that make a regex-based approach unreliable. E.g., while it's illegal on Windows, on Unix, you could make a directory called .*, and that's pretty obviously going to match directories other than itself if interpreted as a regex. Lexical path comparison is already fraught with trouble, and including arbitrary/user-provided strings into regex always requires escaping them, which is why I went for something more reliable, although it turned out not to be portable.

@MarkCallow
Copy link
Collaborator

Closing in favour of alternative fix in PR #1088.

Thanks for the report and this PR.

@MarkCallow MarkCallow closed this Nov 25, 2025
@AnyOldName3
Copy link
Author

Somehow I'd missed the relevant paragraph in the Bash manual about quoting meaning something different within a [[ test. That solution's much simpler.

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.

#1071 broke builds in directories with characters that contain special characters

3 participants