blob: 60c55554e207230b51f782c114ab5b3b7ff455b6 [file] [log] [blame] [view]
Alex Eagleeabe5f72021-09-24 08:24:43 -07001<!-- Generated with Stardoc: http://skydoc.bazel.build -->
2
Alexandre Rostovtsev6e30a772021-10-27 09:13:59 -04003Skylib module containing shell utility functions.
4
nickgooding31ab4c82022-08-30 19:57:34 +01005<a id="shell.array_literal"></a>
Alex Eagleeabe5f72021-09-24 08:24:43 -07006
c-parsons96308532019-02-28 17:43:57 -05007## shell.array_literal
8
9<pre>
10shell.array_literal(<a href="#shell.array_literal-iterable">iterable</a>)
11</pre>
12
13Creates a string from a sequence that can be used as a shell array.
14
15For example, `shell.array_literal(["a", "b", "c"])` would return the string
16`("a" "b" "c")`, which can be used in a shell script wherever an array
17literal is needed.
18
19Note that all elements in the array are quoted (using `shell.quote`) for
20safety, even if they do not need to be.
21
22
Alex Eagleeabe5f72021-09-24 08:24:43 -070023**PARAMETERS**
c-parsons96308532019-02-28 17:43:57 -050024
c-parsons96308532019-02-28 17:43:57 -050025
Alex Eagleeabe5f72021-09-24 08:24:43 -070026| Name | Description | Default Value |
Alexandre Rostovtsev6e30a772021-10-27 09:13:59 -040027| :------------- | :------------- | :------------- |
Alexandre Rostovtsev99ffbbf2024-04-24 17:40:06 -040028| <a id="shell.array_literal-iterable"></a>iterable | A sequence of elements. Elements that are not strings will be converted to strings first, by calling `str()`. | none |
Alexandre Rostovtsev6e30a772021-10-27 09:13:59 -040029
30**RETURNS**
31
32A string that represents the sequence as a shell array; that is,
33parentheses containing the quoted elements.
Alex Eagleeabe5f72021-09-24 08:24:43 -070034
35
nickgooding31ab4c82022-08-30 19:57:34 +010036<a id="shell.quote"></a>
c-parsons96308532019-02-28 17:43:57 -050037
38## shell.quote
39
40<pre>
41shell.quote(<a href="#shell.quote-s">s</a>)
42</pre>
43
44Quotes the given string for use in a shell command.
45
46This function quotes the given string (in case it contains spaces or other
47shell metacharacters.)
48
49
Alex Eagleeabe5f72021-09-24 08:24:43 -070050**PARAMETERS**
c-parsons96308532019-02-28 17:43:57 -050051
Alex Eagleeabe5f72021-09-24 08:24:43 -070052
53| Name | Description | Default Value |
Alexandre Rostovtsev6e30a772021-10-27 09:13:59 -040054| :------------- | :------------- | :------------- |
55| <a id="shell.quote-s"></a>s | The string to quote. | none |
56
57**RETURNS**
58
59A quoted version of the string that can be passed to a shell command.
c-parsons96308532019-02-28 17:43:57 -050060
61