backtick - run a program and stores its output in an environment variable, then execute another program


BACKTICK(1) BSD General Commands Manual BACKTICK(1)

NAME

backtick — run a program and stores its output in an environment variable, then execute another program

SYNOPSIS

In an execlineb(1) script:

backtick [−i −I −x −D default] [−N −n] [[-E | -e] variable { prog1... } prog2...

DESCRIPTION

backtick reads prog1... in an execline-block(7) and unquotes it.

It runs prog1... as a child process and saves its output in memory. This output must not contain a null character.

backtick exec(3)s into prog2..., with variable added to the environment with prog1...’s output as a value.

OPTIONS
−N

Store prog1...’s output as is, including the last newline, if any.

−n

Chomp an ending newline off prog1...’s output. This is the default.

−e

No autoimport. This is the default.

−E

Autoimport. Instead of exec(3)ing into prog2..., exec(3) into ‘importas -ui variable variable prog2...’. This substitutes variable into the command line instead of putting it into the environment.

The other options tell backtick what to do if prog1...’s output is not suitable as the contents of an environment variable (i.e. it contains a null character) or if prog1... crashes or exits nonzero:

−i

backtick exits with an approximation (

cf. execline-exitcodes(7) ) of prog1’s exit code, or 124 if prog1 wrote a null character. This is the default.

−I

The value of variable is set to whatever the start of prog1...’s output is, up to the first null character, or to whatever prog1... wrote before crashing; chomping is applied if required; then execution proceeds.

−x

variable is removed from the environment, and execution proceeds.

−D default

The value of variable is set to default, and execution proceeds.

SEE ALSO

background(1), foreground(1), if(1), ifelse(1), ifte(1), ifthenelse(1), pipeline(1), runblock(1), execline-block(7)

This man page is ported from the authoritative documentation at: https://skarnet.org/software/execline/backtick.html

AUTHORS

Laurent Bercot
Alexis <

[email protected] > (man page port)

BSD February 16, 2021 BSD


Updated 2023-02-15 - jenkler.se | uex.se