Commit 624745cc authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

param: Expand %d to the default cc_command

This is useful for shell script wrappers that can take the original
command as an argument as well as the %{o,s,w} expansions as additional
parameters.
parent 6fde72c6
......@@ -233,6 +233,7 @@ void mgt_vcl_startup(struct cli *, const char *vclsrc, const char *origin,
int mgt_push_vcls(struct cli *, unsigned *status, char **p);
const char *mgt_has_vcl(void);
extern char *mgt_cc_cmd;
extern char *mgt_cc_cmd_def;
extern char *mgt_cc_warn;
extern const char *mgt_vcl_path;
extern const char *mgt_vmod_path;
......
......@@ -765,6 +765,9 @@ MCF_InitParams(struct cli *cli)
mcf_wash_param(cli, pp, MCF_DEFAULT, "default", vsb);
}
VSB_destroy(&vsb);
AN(mgt_cc_cmd);
REPLACE(mgt_cc_cmd_def, mgt_cc_cmd);
}
/*--------------------------------------------------------------------*/
......
......@@ -63,6 +63,7 @@ struct vcc_priv {
};
char *mgt_cc_cmd;
char *mgt_cc_cmd_def;
char *mgt_cc_warn;
const char *mgt_vcl_path;
const char *mgt_vmod_path;
......@@ -154,6 +155,9 @@ run_cc(void *priv)
case 'w':
VSB_cat(sb, mgt_cc_warn);
break;
case 'd':
VSB_cat(sb, mgt_cc_cmd_def);
break;
case '%':
VSB_putc(sb, '%');
break;
......
varnishtest "cc_command and cc_warnings"
varnish v1 -cliok {param.set debug +vcl_keep}
varnish v1 -cliok {param.set cc_command "! printf '%w' >world"}
varnish v1 -cliok {param.set cc_warnings hello}
varnish v1 -cliok {param.set cc_command << EOF
! printf 'd="%%s" w="%%s"' '%d' '%w' >world
EOF}
varnish v1 -errvcl "VCL compilation failed" "backend be none;"
shell -expect hello "cat v1/vcl_*/world"
shell -match {d=".+" w="hello"} "cat v1/vcl_*/world"
......@@ -1534,7 +1534,8 @@ PARAM_STRING(
"dlopen(3) loadable object. Any occurrence of %s in "
"the string will be replaced with the source file name, "
"%o will be replaced with the output file name, and %w "
"will be replaced by the cc_warnings parameter.",
"will be replaced by the cc_warnings parameter. The %d "
"sequence expands to the default value for cc_command.",
/* flags */ MUST_RELOAD | BUILD_OPTIONS,
/* dyn_min_reason */ NULL,
/* dyn_max_reason */ NULL,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment