Subject: Re: [PATCH 3/5] meson: correct path to system config/attribute files

From: Junio C Hamano <[email-masked]>
Date: Thu, 08 May 2025 14:48:22 -0700

Ramsay Jones <[email-masked]> writes:

> -  '-DETC_GITATTRIBUTES="' + get_option('gitattributes') + '"',
> -  '-DETC_GITCONFIG="' + get_option('gitconfig') + '"',
> ...
> +system_attributes = get_option('gitattributes')
> +if system_attributes != ''
> +  libgit_c_args += '-DETC_GITATTRIBUTES="' + system_attributes + '"'
> +else
> +  libgit_c_args += '-DETC_GITATTRIBUTES="' + get_option('sysconfdir') + '/gitattributes"'
> +endif

Just out of curiosity (because this cannot be a regression, since
the original removed one used the same constructs).

I am guessing from the presence of double quote around the value
that these strings are not directly used to invoke the compiler
without involving any shell (in other words, you wouldn't want these
quotes if you are shoving these strings in argv[] yourself to feed
execv()).

How does the above, and get_option() in particular, cope with a
pathname that has letters with special meanings to the shell when
they appear inside double-quote pair (like backquote or backslash or
even a dollar sign)?  On the Makefile side we give VAR_SQ for a raw
variable VAR and use the latter to write something like

        -DETC_GITATTRIBUTES='"$(ETC_GITATTRIBUTES_SQ)"'

to make sure we won't be broken by them.  Is Meson giving us an
equivalent to us for free by simply using get_option() here?

Thanks.