From 55e929c4ed5cd854038c18697123ea94948ebf35 Mon Sep 17 00:00:00 2001
From: Lukas Larsson
Date: Wed, 13 Dec 2017 11:22:45 +0100
Subject: kernel: Add os:cmd/2 with max_size option
---
lib/kernel/doc/src/os.xml | 43 ++++++++++++++++++++++++++++++++++++++-----
1 file changed, 38 insertions(+), 5 deletions(-)
(limited to 'lib/kernel/doc')
diff --git a/lib/kernel/doc/src/os.xml b/lib/kernel/doc/src/os.xml
index 0e9add4161..7ce2f54542 100644
--- a/lib/kernel/doc/src/os.xml
+++ b/lib/kernel/doc/src/os.xml
@@ -38,17 +38,35 @@
most platforms.
+
+
+
+
+
+
+
+ Options for os:cmd/2
+
+ max_size
+ -
+
The maximum size of the data returned by the os:cmd call.
+ See the os:cmd/2
+ documentation for more details.
+
+
+
+
+
+
+
Execute a command in a shell of the target OS.
Executes Command in a command shell of the
- target OS,
- captures the standard output of the command, and returns this
- result as a string. This function is a replacement of
- the previous function unix:cmd/1; they are equivalent on a
- Unix platform.
+ target OS, captures the standard output of the command,
+ and returns this result as a string.
Examples:
LsOut = os:cmd("ls"), % on unix platform
@@ -57,6 +75,21 @@ DirOut = os:cmd("dir"), % on Win32 platform
called from another program (for example, os:cmd/1)
can differ, compared with the standard output of the command
when called directly from an OS command shell.
+ os:cmd/2 was added in kernel-5.5 (OTP-20.2.1). It makes it
+ possible to pass an options map as the second argument in order to
+ control the behaviour of os:cmd. The possible options are:
+
+
+ max_size
+ -
+
The maximum size of the data returned by the os:cmd call.
+ This option is a safety feature that should be used when the command
+ executed can return a very large, possibly infinite, result.
+
+> os:cmd("cat /dev/zero", #{ max_size => 20 }).
+[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
+
+
--
cgit v1.2.3