Skylib module containing shell utility functions.

Macros and Functions

shell.array_literal

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.

Example usage (generated)

load("@bazel_skylib//lib:shell.bzl", "shell")

shell.array_literal(
    # A sequence of elements
    iterable = None,
)

iterable

A sequence of elements. Elements that are not strings will be converted to strings first, by calling str().


shell.quote

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

Example usage (generated)

load("@bazel_skylib//lib:shell.bzl", "shell")

shell.quote(
    # The string to quote.
    s = None,
)

s

The string to quote.