Skip to content

Conversation

@albestro
Copy link
Contributor

@albestro albestro commented Dec 22, 2025

IMHO this helps in different ways:

  • code readability, both on C++ and bash side
  • tracking changes: there is no "workaround" or compromise due to nesting/raw string literals/... it will be easier to understand and apply changes
  • development: being a real bash script, you can edit with your preferred editor (which might provide syntax highlighting, ...)
  • "live"-patching: being a separate file, you can directly source it and use it during development without rebuilding, but actually using the real one

How this is achieved

  • move the raw-string-literal content in a dedicated bash file

  • generate with xxd a C header file at build-time containing the binary representation of the script;

  • the custom target generating the header file is a new dependency of the uenv executable, so whenever the bash script changes, it gets regenerated and `uenv gets rebuilt

  • include the build-time header file replacing the raw-string-literal

  • use string_view to recreate the compile time string starting from the binary representation

  • I should probably add xxd as a requirement

generate at compile time and include file and include it as header
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.

1 participant