From 2c079d855ed87488bdcc6c5c06f59abdb9b85b6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Wei=C3=9Fmann?= Date: Thu, 14 Oct 2021 01:35:14 +0200 Subject: Added warning if run_command is called without the check kwarg --- docs/markdown/External-commands.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'docs/markdown/External-commands.md') diff --git a/docs/markdown/External-commands.md b/docs/markdown/External-commands.md index 772459b..026ed54 100644 --- a/docs/markdown/External-commands.md +++ b/docs/markdown/External-commands.md @@ -8,18 +8,19 @@ As a part of the software configuration, you may want to get extra data by running external commands. The basic syntax is the following. ```meson -r = run_command('command', 'arg1', 'arg2', 'arg3') -if r.returncode() != 0 - # it failed -endif +r = run_command('command', 'arg1', 'arg2', 'arg3', check: true) output = r.stdout().strip() errortxt = r.stderr().strip() ``` +If `check: true` is given, meson will error out if `command` returns with a +non-zero exit code. Alternatively, you can set `check: false` and get the exit +code with `r.returncode()`. + Since 0.52.0, you can pass the command environment as a dictionary: ```meson -run_command('command', 'arg1', 'arg2', env: {'FOO': 'bar'}) +run_command('command', 'arg1', 'arg2', env: {'FOO': 'bar'}, check: true) ``` Since 0.50.0, you can also pass the command [[@env]] object: -- cgit v1.1