diff --git a/core/wasm_shims/cnc_sim_wasm_runtime_probe_main.cc b/core/wasm_shims/cnc_sim_wasm_runtime_probe_main.cc index d664cda..03a3e26 100644 --- a/core/wasm_shims/cnc_sim_wasm_runtime_probe_main.cc +++ b/core/wasm_shims/cnc_sim_wasm_runtime_probe_main.cc @@ -60,6 +60,22 @@ bool wordexp_expands_environment_variables() { return ok; } +bool wordexp_expands_braced_environment_variables() { + setenv("CNC_SIM_WORDEXP_BRACED_PROBE", "linuxcnc-braced-wordexp", 1); + + wordexp_t expanded{}; + if (wordexp("${CNC_SIM_WORDEXP_BRACED_PROBE}/subroutines", &expanded, 0) != 0) { + return false; + } + + const bool ok = expanded.we_wordc == 1 && + expanded.we_wordv && + expanded.we_wordv[0] && + std::strcmp(expanded.we_wordv[0], "linuxcnc-braced-wordexp/subroutines") == 0; + wordfree(&expanded); + return ok; +} + bool hal_lookup_is_unavailable() { if (hal_init("cnc_sim_wasm_runtime_probe") != 1) { return false; @@ -109,6 +125,9 @@ int main() { if (!wordexp_expands_environment_variables()) { return 6; } + if (!wordexp_expands_braced_environment_variables()) { + return 8; + } if (!hal_lookup_is_unavailable()) { return 7; }