diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2021-01-01 21:06:00 +0000 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2021-01-01 21:06:00 +0000 |
commit | 129160ec854dca4c3fedb5bcfbcb56930371da0f (patch) | |
tree | 53bf797418ac5e9b99c41ca0382c87b82421e5de /dev-util/meson-format-array/files | |
parent | 441d1370330332b7d78f238d2f5e13f7aed5e4e0 (diff) |
gentoo new year resync : 01.01.2021
Diffstat (limited to 'dev-util/meson-format-array/files')
-rw-r--r-- | dev-util/meson-format-array/files/meson-format-array | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/dev-util/meson-format-array/files/meson-format-array b/dev-util/meson-format-array/files/meson-format-array new file mode 100644 index 000000000000..d2bf49ba8e59 --- /dev/null +++ b/dev-util/meson-format-array/files/meson-format-array @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +# Copyright 2020 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +import itertools +import shlex +import sys + +def quote(s): + return "'" + s.replace("\\", "\\\\").replace("'", "\\'") + "'" + +def main(args): + # Split each argument according to shell rules + args = (shlex.split(x) for x in args) + + # Flatten the resulting list of lists + args = itertools.chain.from_iterable(args) + + # Add quotes and escape embedded quotes + args = (quote(x) for x in args) + + # Format the result + print("[" + ", ".join(args) + "]") + +if __name__ == "__main__": + main(sys.argv[1:]) |