2021-09-24 15:24:43 +00:00
<!-- Generated with Stardoc: http://skydoc.bazel.build -->
2021-10-27 13:13:59 +00:00
Skylib module containing shell utility functions.
2022-08-30 18:57:34 +00:00
< a id = "shell.array_literal" > < / a >
2021-09-24 15:24:43 +00:00
2019-02-28 22:43:57 +00:00
## shell.array_literal
< pre >
shell.array_literal(< a href = "#shell.array_literal-iterable" > iterable< / a > )
< / pre >
Creates a string from a sequence that can be used as a shell array.
For example, `shell.array_literal(["a", "b", "c"])` would return the string
`("a" "b" "c")` , which can be used in a shell script wherever an array
literal is needed.
Note that all elements in the array are quoted (using `shell.quote` ) for
safety, even if they do not need to be.
2021-09-24 15:24:43 +00:00
**PARAMETERS**
| Name | Description | Default Value |
2021-10-27 13:13:59 +00:00
| :------------- | :------------- | :------------- |
2024-04-24 21:40:06 +00:00
| < 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 |
2021-10-27 13:13:59 +00:00
**RETURNS**
A string that represents the sequence as a shell array; that is,
parentheses containing the quoted elements.
2019-02-28 22:43:57 +00:00
2022-08-30 18:57:34 +00:00
< a id = "shell.quote" > < / a >
2021-09-24 15:24:43 +00:00
2019-02-28 22:43:57 +00:00
## shell.quote
< pre >
shell.quote(< a href = "#shell.quote-s" > s< / a > )
< / pre >
Quotes the given string for use in a shell command.
This function quotes the given string (in case it contains spaces or other
shell metacharacters.)
2021-09-24 15:24:43 +00:00
**PARAMETERS**
| Name | Description | Default Value |
2021-10-27 13:13:59 +00:00
| :------------- | :------------- | :------------- |
| < a id = "shell.quote-s" > < / a > s | The string to quote. | none |
**RETURNS**
A quoted version of the string that can be passed to a shell command.
2019-02-28 22:43:57 +00:00