Added shtpl utility

This commit is contained in:
dig 2018-10-09 16:54:38 +02:00
parent fabb36eaa1
commit 7604d2bd7b
3 changed files with 34 additions and 0 deletions

10
shtpl/boucle.shtpl Executable file
View File

@ -0,0 +1,10 @@
#!/home/dig/bin/shtpl
Coucou $WHO !
$(
for ((i=0 ; $nbrBoucle - $i ; i++))
do
echo "$i+100"
done
)

11
shtpl/shtpl Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
eval "echo \"$(cat $1 | sed '
1{ /#\!.*shtpl/ d }
s/"/\\"/g
')\""
#eval "echo \"$(perl -p -e 's/"/\\"/g' $1)\""

13
shtpl/test.sh Executable file
View File

@ -0,0 +1,13 @@
# With env variables
## On single line
WHO=Doctor nbrBoucle=5 ./boucle.shtpl
## Multiline
WHO=Doctor \
nbrBoucle=5 \
./boucle.shtpl
# Save result to file
WHO=Doctor ./boucle.shtpl > final.txt