Awkl
Loading...
Searching...
No Matches
cmd Namespace Reference

Functions

string quote (string x)
 

 
unassigned quote (array< string > A)
 Shell-quote strings in an array.
 
string quote0 (string x)
 Shell-quote nullbyte separated strings.
 
string read (string c, string cb)
 Run a command and return its output.
 
string extern (string c)
 Run a single external command and return its output.
 
unassigned write (string c, string stdin, string cb)
 

 
unassigned write (string c, array< string > A, string cb)
 Write text to the standard input of a command to be run.
 
unassigned writeFile (string c, string f, string cb)
 Write file contents as standard input of a command to be run.
 
unassigned writeFile (string c, array< string > F, string cb)
 Write files' contents as standard input of a command to be run.
 
string writeRead (string c, string stdin, string cbr, string cbw)
 

 
string writeRead (string c, array< string > A, string cbr, string cbw)
 Run a command passing it input text and return its output.
 
string writeFileRead (string c, string f, string cbr, string cbw)
 Run a command passing it a file content as input and return its output.
 
auto writeCmdRead (cin, cout, cbr, cbw)
 Run a command passing it another command's output as input and return its output.
 
string writeFileRead (string c, array< string > F, string cbr, string cbw)
 Run a command passing it a files' contents as input and return its output.
 
auto bash (c)
 Run a command with the Bash shell and return its exit status.
 
auto bashRead (c)
 Run a command with the Bash shell and return its output.
 

Function Documentation

◆ bash()

auto cmd::bash ( c )

Run a command with the Bash shell and return its exit status.

◆ bashRead()

auto cmd::bashRead ( c )

Run a command with the Bash shell and return its output.

◆ extern()

string cmd::extern ( string c)

Run a single external command and return its output.

Parameters
cCommand to run. If it contains a nullbyte, arguments are nullbyte-separated
Returns
Standard output of the command
Note
Last linebreak is chomped as there is no way of distinguish it from an EOF, this is a limitation of gawk's getline

◆ quote() [1/2]

unassigned cmd::quote ( array< string > A)

Shell-quote strings in an array.

Parameters
[in,out]ASource array whose elements are to be shell-quoted in-place: safely usable as Unix shell arguments
Returns

◆ quote() [2/2]

string cmd::quote ( string x)


Shell-quote a string

Parameters
xOriginal string
Returns
Quoted version of the string safely usable as a Unix shell argument

◆ quote0()

string cmd::quote0 ( string x)

Shell-quote nullbyte separated strings.

Parameters
xContaining string whose nullbyte separated elements are to be shell-quoted
Returns
Space joined string of shellquoted elements

◆ read()

string cmd::read ( string c,
string cb )

Run a command and return its output.

Parameters
cCommand to run
cbCallback function for each line read. Optional
Returns
Standard output of the command
Note
Last linebreak is chomped as there is no way of distinguish it from an EOF, this is a limitation of gawk's getline

◆ write() [1/2]

unassigned cmd::write ( string c,
array< string > A,
string cb )

Write text to the standard input of a command to be run.

Parameters
cCommand to run
AArray of strings passed to the command as standard input
cbCallback function for each line written. Optional
Returns

◆ write() [2/2]

unassigned cmd::write ( string c,
string stdin,
string cb )


Write text to the standard input of a command to be run

Parameters
cCommand to run
stdinStandard input text passed to the command
cbCallback function for each line written. Optional
Returns

◆ writeCmdRead()

auto cmd::writeCmdRead ( cin ,
cout ,
cbr ,
cbw  )

Run a command passing it another command's output as input and return its output.

Note
This is similar to a pipe in a non-streaming fashion. In shell scripting terms it would be like cout <<< "$(cin)", not cin | cout

◆ writeFile() [1/2]

unassigned cmd::writeFile ( string c,
array< string > F,
string cb )

Write files' contents as standard input of a command to be run.

Parameters
cCommand to run
FArray of file names whose contents are passed as standard input to the command
cbCallback function for each line written. Optional
Returns

◆ writeFile() [2/2]

unassigned cmd::writeFile ( string c,
string f,
string cb )

Write file contents as standard input of a command to be run.

Parameters
cCommand to run
fFile name whose content are passed as standard input to the command
cbCallback function for each line written. Optional
Returns

◆ writeFileRead() [1/2]

string cmd::writeFileRead ( string c,
array< string > F,
string cbr,
string cbw )

Run a command passing it a files' contents as input and return its output.

Parameters
cCommand to run
FArray of file names whose contents are passed as standard input to the command
cbrCallback function for each line read. Optional
cbwCallback function for each line written. Optional
Returns
Standard output of the command

◆ writeFileRead() [2/2]

string cmd::writeFileRead ( string c,
string f,
string cbr,
string cbw )

Run a command passing it a file content as input and return its output.

Parameters
cCommand to run
fFile name whose content are passed as standard input to the command
cbrCallback function for each line read. Optional
cbwCallback function for each line written. Optional
Returns
Standard output of the command

◆ writeRead() [1/2]

string cmd::writeRead ( string c,
array< string > A,
string cbr,
string cbw )

Run a command passing it input text and return its output.

Parameters
cCommand to run
AArray of strings passed to the command as standard input
cbrCallback function for each line read. Optional
cbwCallback function for each line written. Optional
Returns
Standard output of the command

◆ writeRead() [2/2]

string cmd::writeRead ( string c,
string stdin,
string cbr,
string cbw )


Run a command passing it input text and return its output

Parameters
cCommand to run
stdinStandard input text passed to the command
cbrCallback function for each line read. Optional
cbwCallback function for each line written. Optional
Returns
Standard output of the command