aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/markdown/External-commands.md11
-rw-r--r--docs/markdown/FAQ.md2
-rw-r--r--docs/markdown/howtox.md2
-rw-r--r--docs/markdown/snippets/check_false_warning.md14
-rw-r--r--docs/yaml/functions/run_command.yaml3
5 files changed, 24 insertions, 8 deletions
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:
diff --git a/docs/markdown/FAQ.md b/docs/markdown/FAQ.md
index 2a37651..74696f8 100644
--- a/docs/markdown/FAQ.md
+++ b/docs/markdown/FAQ.md
@@ -103,7 +103,7 @@ Then you need to run this script in your Meson file, convert the
output into a string array and use the result in a target.
```meson
-c = run_command('grabber.sh')
+c = run_command('grabber.sh', check: true)
sources = c.stdout().strip().split('\n')
e = executable('prog', sources)
```
diff --git a/docs/markdown/howtox.md b/docs/markdown/howtox.md
index 5c64bcb..91098aa 100644
--- a/docs/markdown/howtox.md
+++ b/docs/markdown/howtox.md
@@ -133,7 +133,7 @@ endif
## Set a command's output to configuration
```meson
-txt = run_command('script', 'argument').stdout().strip()
+txt = run_command('script', 'argument', check: true).stdout().strip()
cdata = configuration_data()
cdata.set('SOMETHING', txt)
configure_file(...)
diff --git a/docs/markdown/snippets/check_false_warning.md b/docs/markdown/snippets/check_false_warning.md
new file mode 100644
index 0000000..50214b7
--- /dev/null
+++ b/docs/markdown/snippets/check_false_warning.md
@@ -0,0 +1,14 @@
+## Warning if check kwarg of run_command is missing
+
+The `check` kwarg of `run_command` currently defaults to `false`.
+Because we want to change that, running
+```meson
+run_command('cmd')
+```
+now results in:
+```text
+WARNING: You should add the boolean check kwarg to the run_command call.
+ It currently defaults to false,
+ but it will default to true in future releases of meson.
+ See also: https://github.com/mesonbuild/meson/issues/9300
+```
diff --git a/docs/yaml/functions/run_command.yaml b/docs/yaml/functions/run_command.yaml
index 091c030..288cd05 100644
--- a/docs/yaml/functions/run_command.yaml
+++ b/docs/yaml/functions/run_command.yaml
@@ -27,7 +27,8 @@ kwargs:
default: false
description: |
If `true`, the exit status code of the command will be checked,
- and the configuration will fail if it is non-zero.
+ and the configuration will fail if it is non-zero. Note that
+ the default value will be `true` in future releases.
env:
type: env | list[str] | dict[str]