Execline Memo

Posted on Tue 07 January 2020 in coding

exec family

param several args all args as one array
file execlp(file, arg1,arg2, ...) execvp(file, argv[])
path execl(path, ...) execv(path, ...)
env execle(..., env) execve(..., env)

after exec, the file descriptor of a process is saved in another "fd-holder" process, which can be accessed by the logger (and "socker activation").

Variable Substitution - Quoting

The official doc has a section about quoting.

At first I was confused about the identical output of

define A blah
echo \\${A}


define A blah
echo \\\${A}

Perusing the official Example for a while, I suddenly realized that backslash is reduced (mod2) for one pass, then parsed against the sub/nosub rule

Compare the 2 output lines of this script:

foreground { echo $A \\$A \\\\$A \\\\\\$A \\\\\\\\$A \\\\\\\\\\$A }
define A blah
echo $A \\$A \\\\$A \\\\\\$A \\\\\\\\$A \\\\\\\\\\$A


foreground { echo \$A \\\$A \\\\\$A \\\\\\\$A \\\\\\\\\$A \\\\\\\\\\\$A }
define A blah
echo \$A \\\$A \\\\\$A \\\\\\\$A \\\\\\\\\$A \\\\\\\\\\\$A

Another Notable Tutorial


An example

This is a script to clean up Gentoo's world set:

#!/bin/execlineb -P
forbacktickx -p PKG {
    cat /var/lib/portage/world
importas -u p PKG
if {
    redirfd -w 1 /dev/null qdepends -QqC $p # True = exit0 = has rdep
backtick CLEAN {
    emerge -pqc $p
importas -u c CLEAN
if {
    test -z $c # no output = rdep retains it = to purge
echo $p