Auto-éditer un wikilivre/Annexer (Version internationalisée)/src/killalldoc.sh

killalldoc.sh (killalldoc functions)Modifier

#!/bin/bash
#H File killalldoc.sh
#D killalldoc.sh documentation
#D ---------------------------
#D This funtions clean sripts to create executable files for translations with
#D   compil2bin executable script
#D
#D The 'killalldoc' function eliminates all comment lines starting with #D #M 
#D   #O #P #T in the first column.
#D
#D The killDMOPT function replaces all comment lines starting with #D #M #O #P
#D   #T in the first column with a blank line. This keeps the line number of 
#D   the translations.
#D
#D killOPT function replaces all comment lines starting with #O #P #T in first
#D   column with a blank line. This keeps the line number for the translations

VERSION=211019
if [ "$1" = "--v" ];then echo "killalldoc.sh version: $VERSION"; exit 0;fi

function killOPT ()
{
  if test -z $1; then return -1; fi
  awk '{
  if ($1=="#O" || $1=="#P" || $1=="#T")  {print " "} # replace with blank line
  else {print $0}
  }' $1
}

function killDMOPT ()
{
  if test -z $1; then return -1; fi
  awk '{
  if ($1=="#D" || $1=="#M" || $1=="#O" || $1=="#P" || $1=="#T")  {print " "} # replace with blank line
  else {print $0}
  }' $1
}

function killALLDOC ()
{
  if test -z $1; then return -1; fi
  awk '{
  if ($1=="#D" || $1=="#M" || $1=="#O" || $1=="#P" || $1=="#T")  {;} # do not replace with an empty line
  else {print $0}
  }' $1
}

test_killalldoc.bashModifier

#!/bin/bash
#H File : test_killalldoc.bash in ~/Add_appendix/tests/1-annex.lib/15-killalldoc.sh

VERSION=211019

clear
echo "syntax of $0 [ --docu ]"
echo "test_killalldoc.sh version: $VERSION"

source killalldoc.sh
Srcdir='../../01-sbsrc'
mkdir -p ./bin
Bindir=./bin
Libdir=../../../lib/annex.lib
Verbose="true"

#P killalldoc script version
./killalldoc.sh --v; echo "----"
#P wait 5 seconds
sleep 5

#P funtion killALLDOC invocation
killALLDOC $Srcdir/compil2bin.sh
read -s -e -n 1 -t 60 -p "Continue ?: y/n" Inkey; echo
if [ "$Inkey" != 'y' ]; then echo "exit"; exit 0; fi

#P funtion killDMOPT invocation
killDMOPT $Srcdir/compil2bin.sh
read -s -e -n 1 -t 60 -p "Continue ?: y/n" Inkey; echo
if [ "$Inkey" != 'y' ]; then echo "exit"; exit 0; fi

#P function killOPT invoacation
killOPT $Srcdir/cp-src2bin.sh
read -s -e -n 1 -t 60 -p "Continue ?: y/n" Inkey; echo
if [ "$Inkey" != 'y' ]; then echo "exit"; exit 0; fi

#P documentation invocation for 'sbin/doc/cpcleaned2bin.docu'
if [ "$1" = "--docu" ] && test -d ../../../sbin/doc; then
clear; echo "$0 version $VERSION"; echo "----"
cat killalldoc.sh | grep "#D" | tee ../../../sbin/doc/cpcleaned2bin.docu
fi
#P Note: The manuals must be extracted with the command grep -v "#M ". 
#P There must always be a space between #M and the text to extract.