xref: /aosp_15_r20/external/bazel-skylib/docs/shell_doc.md (revision bcb5dc7965af6ee42bf2f21341a2ec00233a8c8a)
1<!-- Generated with Stardoc: http://skydoc.bazel.build -->
2
3Skylib module containing shell utility functions.
4
5<a id="shell.array_literal"></a>
6
7## 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
23**PARAMETERS**
24
25
26| Name  | Description | Default Value |
27| :------------- | :------------- | :------------- |
28| <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 |
29
30**RETURNS**
31
32A string that represents the sequence as a shell array; that is,
33parentheses containing the quoted elements.
34
35
36<a id="shell.quote"></a>
37
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
50**PARAMETERS**
51
52
53| Name  | Description | Default Value |
54| :------------- | :------------- | :------------- |
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.
60
61
62