aboutsummaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-09 14:48:33 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-09 14:48:33 -0400
commit6ea6aadd963a216e4e321e500515846201d213a5 (patch)
treeea85ac24f6dd479cd2f052b63c65dbe3e253b23e /compile.c
parent43c595cafe3a09c52a098774671bb55c7e80f128 (diff)
Correctly clean up CLI args that are paths
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/compile.c b/compile.c
index c3b6325a..db2c6930 100644
--- a/compile.c
+++ b/compile.c
@@ -3222,7 +3222,7 @@ CORD compile_cli_arg_call(env_t *env, CORD fn_name, type_t *fn_type)
}
case TextType: {
code = CORD_all(code, "else if (pop_flag(argv, &i, \"", flag, "\", &flag)) {\n",
- "$", arg->name, " = flag;\n",
+ "$", arg->name, " = ", streq(Match(t, TextType)->lang, "Path") ? "Path$cleanup(flag)" : "flag",";\n",
arg->name, "$is_set = yes;\n"
"}\n");
break;
@@ -3304,6 +3304,9 @@ CORD compile_cli_arg_call(env_t *env, CORD fn_name, type_t *fn_type)
"if (i < argc) {");
if (t->tag == TextType) {
code = CORD_all(code, "$", arg->name, " = Text$from_str(argv[i]);\n");
+ if (streq(Match(t, TextType)->lang, "Path"))
+ code = CORD_all(code, "$", arg->name, " = Path$cleanup($", arg->name, ");\n");
+
} else if (t->tag == EnumType) {
env_t *enum_env = Match(t, EnumType)->env;
for (tag_t *tag = Match(t, EnumType)->tags; tag; tag = tag->next) {