function::user_string_n_quoted - Linux
Overview
The function::user_string_n_quoted
command generates a string with the N
-th user string in the function’s signature, quoted with a double quote ("
). This is useful for generating SQL queries or other code that requires quoted strings.
Syntax
function::user_string_n_quoted(n: int, options: nullable array of str) -> str
The following arguments are required:
n
: The index of the user string to quote.
The following options are available:
esc_quotes
: If true, quotes within the string will be escaped.
Examples
The following command generates a quoted string with the first user string in the function’s signature:
function::user_string_n_quoted(1)
The following command generates a quoted string with the second user string in the function’s signature, with quotes escaped:
function::user_string_n_quoted(2, {"esc_quotes": true})
Common Issues
If the user string contains a double quote, it must be escaped using a backslash (\
) if the esc_quotes
option is not set to true
.
Integration
The function::user_string_n_quoted
command can be used with other Linux commands or tools to generate SQL queries or other code that requires quoted strings. For example, the following command generates a SQL query that selects the first column from the users
table:
printf "SELECT %s FROM users" "$(function::user_string_n_quoted 1)"
Related Commands
function::user_string_n
: Generates a string with theN
-th user string in the function’s signature.function::user_string_n_literal
: Generates a string with theN
-th user string in the function’s signature, quoted with a single quote ('
).