Skip to content

LP Examples¤

LP Source:

 ```bash lp asserts=Hello fmt=xt_flat session=foo
 echo "Hello World!"
 ```

Result:

$ echo "Hello World!"                                 
Hello World!

LP Source:

 ```bash lp asserts=Hello fmt=xt_flat
 ls -lta /etc | grep hosts # lp: asserts=hosts
 echo "Hello World!"       # lp: asserts="[World and Hello] or Foo" 
 ```

Result:

$ ls -lta /etc | grep hosts
-rw-r--r--   1 root     root        326 Oct  4 21:02 hosts
-rw-r--r--   1 root     root        411 Sep  8 21:41 hosts.allow
-rw-r--r--   1 root     root        711 Sep  8 21:41 hosts.deny
$ echo "Hello World!"      
Hello World!

Defining a function for later use:

LP Source:

 ```bash lp new_session=test
 say_hello () { 
     echo -e "Hello, from \n"$(env | grep -i tmux)""; 
 }
 ```

Result:

$ say_hello () { 
    echo -e "Hello, from \n"$(env | grep -i tmux)""; 
}

$ say_hello () {    
>     echo -e "Hello, from \n"$(env | grep -i tmux)"";                          
> }                 
$

Heredocs¤

the example includes the previously defined function:

LP Source:

 ```bash lp session=test asserts=TMUX
 echo $0 # lp: expect=bash
 export -f say_hello
 /bin/bash # lp: expect=
 echo $0 # lp: expect=bash
 say_hello
 R="\x1b["; r="${R}1;31m"
 echo -e "Means: We do have
 > - $r Cross block sessions  ${R}0m
 > - $r Blocking commands/subshells     ${R}0m
 > - and...${R}4m$r Full Ansi
 > "
 ```

Result:

$ echo $0
$ export -f say_hello
$ /bin/bash
$ echo $0
$ say_hello
$ R="\x1b["; r="${R}1;31m"
$ echo -e "Means: We do have
- $r Cross block sessions  ${R}0m
- $r Blocking commands/subshells     ${R}0m
- and...${R}4m$r Full Ansi
"

$ echo $0           
-bash               
$
$ export -f say_hello
$ /bin/bash
runner@fv-az135-986:~/work/docutools/docutools$                                 
runner@fv-az135-986:~/work/docutools/docutools$ echo $0                         
/bin/bash           
runner@fv-az135-986:~/work/docutools/docutools$
runner@fv-az135-986:~/work/docutools/docutools$ say_hello                 
Hello, from         
TMUX=/tmp/tmux-1001/default,2535,20 TMUX_PANE=%20 BASH_FUNC_say_hello%%=() { echo -e "Hello, from   
"$(env | grep -i tmux)""
runner@fv-az135-986:~/work/docutools/docutools$ R="\x1b["; r="${R}1;31m"
runner@fv-az135-986:~/work/docutools/docutools$ echo -e "Means: We do have      
> - $r Cross block sessions  ${R}0m     
> - $r Blocking commands/subshells     ${R}0m                                   
> - and...${R}4m$r Full Ansi            
> "                 
Means: We do have   
-  Cross block sessions                 
-  Blocking commands/subshells          
- and... Full Ansi

runner@fv-az135-986:~/work/docutools/docutools$        


You can tmux att -t test to inspect what is going on.