[Mesa-dev] [PATCH 12/14] util/gen_xmlpool: Don't write via shell redirection

Emil Velikov emil.l.velikov at gmail.com
Wed Oct 31 18:18:18 UTC 2018

On Fri, 26 Oct 2018 at 18:25, Dylan Baker <dylan at pnwbakers.com> wrote:
> This is bad for a couple of reasons, but the worst is that it gets the
> shell involved. When the shell gets involved we can start running into
> problems with LANG, namely LANG=C. This is particularly obnoxious for
> translation files, since there is a very high likelyhood of running into
> unicode in them. If we write it in python through file.write we don't
> have this problem as python just shovels bits into a file, and the shell
> doesn't know, and thus doesn't care.

In case you want to omit the "inspiring" unicode topic, one could also use:

Since we use python to generate the code/data, simply write it to a
file. There's no point in printing it to stdout only to redirect
stdout to a file.
Bonus points: the python and build system code is shorter and easier to read.

> @@ -166,6 +156,7 @@ reDESC_END = re.compile(r'\s*DRI_CONF_DESC_END')
>  def main():
>      parser = argparse.ArgumentParser()
>      parser.add_argument('template')
> +    parser.add_argument('outfile')
Since the existing invocation and order is pretty random and magical,
I'd reuse the approach from rest of mesa
The below will make things dead obvious. We could handle the rest as
well... but not a priority IMHO.

parser.add_argument('-o', '--output', type=str ...., required=True)

With the argument tweak (and invocations updated of course)
Reviewed-by: Emil Velikov <emil.velikov at collabora.com>


More information about the mesa-dev mailing list