Alex Eagle | eabe5f7 | 2021-09-24 08:24:43 -0700 | [diff] [blame] | 1 | <!-- Generated with Stardoc: http://skydoc.bazel.build --> |
| 2 | |
Alexandre Rostovtsev | 6e30a77 | 2021-10-27 09:13:59 -0400 | [diff] [blame] | 3 | Skylib module containing shell utility functions. |
| 4 | |
nickgooding | 31ab4c8 | 2022-08-30 19:57:34 +0100 | [diff] [blame] | 5 | <a id="shell.array_literal"></a> |
Alex Eagle | eabe5f7 | 2021-09-24 08:24:43 -0700 | [diff] [blame] | 6 | |
c-parsons | 9630853 | 2019-02-28 17:43:57 -0500 | [diff] [blame] | 7 | ## shell.array_literal |
| 8 | |
| 9 | <pre> |
| 10 | shell.array_literal(<a href="#shell.array_literal-iterable">iterable</a>) |
| 11 | </pre> |
| 12 | |
| 13 | Creates a string from a sequence that can be used as a shell array. |
| 14 | |
| 15 | For 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 |
| 17 | literal is needed. |
| 18 | |
| 19 | Note that all elements in the array are quoted (using `shell.quote`) for |
| 20 | safety, even if they do not need to be. |
| 21 | |
| 22 | |
Alex Eagle | eabe5f7 | 2021-09-24 08:24:43 -0700 | [diff] [blame] | 23 | **PARAMETERS** |
c-parsons | 9630853 | 2019-02-28 17:43:57 -0500 | [diff] [blame] | 24 | |
c-parsons | 9630853 | 2019-02-28 17:43:57 -0500 | [diff] [blame] | 25 | |
Alex Eagle | eabe5f7 | 2021-09-24 08:24:43 -0700 | [diff] [blame] | 26 | | Name | Description | Default Value | |
Alexandre Rostovtsev | 6e30a77 | 2021-10-27 09:13:59 -0400 | [diff] [blame] | 27 | | :------------- | :------------- | :------------- | |
Alexandre Rostovtsev | 99ffbbf | 2024-04-24 17:40:06 -0400 | [diff] [blame] | 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 | |
Alexandre Rostovtsev | 6e30a77 | 2021-10-27 09:13:59 -0400 | [diff] [blame] | 29 | |
| 30 | **RETURNS** |
| 31 | |
| 32 | A string that represents the sequence as a shell array; that is, |
| 33 | parentheses containing the quoted elements. |
Alex Eagle | eabe5f7 | 2021-09-24 08:24:43 -0700 | [diff] [blame] | 34 | |
| 35 | |
nickgooding | 31ab4c8 | 2022-08-30 19:57:34 +0100 | [diff] [blame] | 36 | <a id="shell.quote"></a> |
c-parsons | 9630853 | 2019-02-28 17:43:57 -0500 | [diff] [blame] | 37 | |
| 38 | ## shell.quote |
| 39 | |
| 40 | <pre> |
| 41 | shell.quote(<a href="#shell.quote-s">s</a>) |
| 42 | </pre> |
| 43 | |
| 44 | Quotes the given string for use in a shell command. |
| 45 | |
| 46 | This function quotes the given string (in case it contains spaces or other |
| 47 | shell metacharacters.) |
| 48 | |
| 49 | |
Alex Eagle | eabe5f7 | 2021-09-24 08:24:43 -0700 | [diff] [blame] | 50 | **PARAMETERS** |
c-parsons | 9630853 | 2019-02-28 17:43:57 -0500 | [diff] [blame] | 51 | |
Alex Eagle | eabe5f7 | 2021-09-24 08:24:43 -0700 | [diff] [blame] | 52 | |
| 53 | | Name | Description | Default Value | |
Alexandre Rostovtsev | 6e30a77 | 2021-10-27 09:13:59 -0400 | [diff] [blame] | 54 | | :------------- | :------------- | :------------- | |
| 55 | | <a id="shell.quote-s"></a>s | The string to quote. | none | |
| 56 | |
| 57 | **RETURNS** |
| 58 | |
| 59 | A quoted version of the string that can be passed to a shell command. |
c-parsons | 9630853 | 2019-02-28 17:43:57 -0500 | [diff] [blame] | 60 | |
| 61 | |