2
0
Fork 0
mirror of https://github.com/bazelbuild/bazel-skylib synced 2024-11-27 05:43:25 +00:00
bazel-skylib/docs/shell_doc.md
Alexandre Rostovtsev 99ffbbf8a4
Prepare release 1.6.0 (#496)
And take the opportunity to reformat docs using a more modern Stardoc release
2024-04-24 17:40:06 -04:00

1.5 KiB
Executable file

Skylib module containing shell utility functions.

shell.array_literal

shell.array_literal(iterable)

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.

PARAMETERS

Name Description Default Value
iterable A sequence of elements. Elements that are not strings will be converted to strings first, by calling str(). none

RETURNS

A string that represents the sequence as a shell array; that is, parentheses containing the quoted elements.

shell.quote

shell.quote(s)

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.)

PARAMETERS

Name Description Default Value
s The string to quote. none

RETURNS

A quoted version of the string that can be passed to a shell command.