diff options
author | Mike Gilbert <floppym@gentoo.org> | 2020-12-28 17:22:14 -0500 |
---|---|---|
committer | Mike Gilbert <floppym@gentoo.org> | 2020-12-28 17:32:58 -0500 |
commit | 3e391ef7abaf60b6a6966121a586b6e69b43f080 (patch) | |
tree | 463eec5888d54d056a789e37e4b143414e713751 /dev-util/meson-format-array/files | |
parent | net-misc/croc: bump to 8.6.7 (diff) | |
download | gentoo-3e391ef7abaf60b6a6966121a586b6e69b43f080.tar.gz gentoo-3e391ef7abaf60b6a6966121a586b6e69b43f080.tar.bz2 gentoo-3e391ef7abaf60b6a6966121a586b6e69b43f080.zip |
dev-util/meson-format-array: new package
Bug: https://bugs.gentoo.org/759433
Signed-off-by: Mike Gilbert <floppym@gentoo.org>
Diffstat (limited to 'dev-util/meson-format-array/files')
-rw-r--r-- | dev-util/meson-format-array/files/meson-format-array | 24 |
1 files changed, 24 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..a6d722dc30b6 --- /dev/null +++ b/dev-util/meson-format-array/files/meson-format-array @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 + +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:]) |