mesonbuild/scripts/dirchanger.py
raw| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # Copyright 2015-2016 The Meson development team |
| 3 | |
| 4 | from __future__ import annotations |
| 5 | |
| 6 | '''CD into dir given as first argument and execute |
| 7 | the command given in the rest of the arguments.''' |
| 8 | |
| 9 | import os, subprocess, sys |
| 10 | import typing as T |
| 11 | |
| 12 | def run(args: T.List[str]) -> int: |
| 13 | dirname = args[0] |
| 14 | command = args[1:] |
| 15 | |
| 16 | os.chdir(dirname) |
| 17 | return subprocess.call(command) |
| 18 | |
| 19 | if __name__ == '__main__': |
| 20 | sys.exit(run(sys.argv[1:])) |