fn: system
[contents]

Contents

Syntax

The syntax for sys/system calls is:

f++:  
sys{options}(string)
system{options}(string)

n++:  
@sys{options}(string)
@system{options}(string)

Description

The sys/system function is for executing system calls/commands, it either:

  • takes a single string parameter which is the system call/command to execute; or
  • takes zero parameters and the call is followed by a code-block to execute

Note: system calls are run from the project root directory so all paths should start from there. Also do not change directory in your system calls or scripts/programs they call as it will mess up the other threads that are also building output files. If you really must change directories in your scripts then you will have to set the number of build threads to 1 and change back to the project root directory before each script ends.

Note: system calls do not scale very well to hundreds of thousands of calls, it is much better to combine as much as possible in to as few script/system calls as possible for very large projects (moving stuff to the pre/post build scripts is the best place, you can output stuff to file and process the files when building). For example if possible it is much faster to have a few pre-build scripts to download text from multiple urls using cURL, and/or make all the api calls, all the database queries, and work on JSON data needed and distribute the needed output in to different files to be inputted when needed. Note that file-specific build scripts have the benefit of running in parallel to each other, whereas project-wide build scripts do not.

Options

The following options are available for sys/system calls:

option description
content add content file path of file being built as first input parameter to script/program
console print script output to console
inject or inj inject in to file being built after parsing with underlying shell
!o do not add script output to file being built
pb parse code-block following call before saving to script path for running
raw inject in to file being built raw
!ret do not return script/program return value
option description

f++ example

Examples of system being used with f++:

system("ls *.txt")
system("./script.rb")

system
{
	x=10
	echo $x
}

n++ example

Examples of system being used with n++:

@system("ls *.txt")
@system('pandoc -o out.html file.md')
@system("curl -sS https://pastebin.com/raw/atjKuxY6")
@system("./script.rb")

@system
{
	x=10
	echo $x
}