X-Git-Url: https://mop.ddnsfree.com/gitweb/?p=populate.git;a=blobdiff_plain;f=populate.sh;fp=populate.sh;h=e39c3cd1542a071a69c9f3358ca5de2863f202a9;hp=6dec3fa325900dcdfb9f6f69527ea4838844cbb5;hb=4e6e7b2764e1b82128a21f1dbe671e05f7438bbc;hpb=517f149b3054c644325d3dfc9927583e6409fee8 diff --git a/populate.sh b/populate.sh index 6dec3fa..e39c3cd 100755 --- a/populate.sh +++ b/populate.sh @@ -1,6 +1,6 @@ #!/bin/bash # set -x - +# export PS4='+${BASH_SOURCE}:${LINENO}:${FUNCNAME[0]}: ' # # populate.sh # @@ -99,7 +99,7 @@ function unsedify() { else cat fi - ) | sed 's/\(["\\\/\$]\)/\\\1/g' + ) | sed 's/\(["\\\/\$&]\)/\\\1/g' return 0 } @@ -113,7 +113,7 @@ function formatify() { fi ) | ( if [ "$1" = "tex" ]; then - sed 's/à/\\`a/g;s/è/\\`e/g;s/ì/\\`i/g;s/ò/\\`o/g;s/ù/\\`u/g;s/áéíóú/\\'"'"'a/g; + sed 's/&/\\&/g;s/à/\\`a/g;s/è/\\`e/g;s/ì/\\`i/g;s/ò/\\`o/g;s/ù/\\`u/g;s/áéíóú/\\'"'"'a/g; s/é/\\'"'"'e/g;s/í/\\'"'"'i/g;s/ó/\\'"'"'o/g;s/ú/\\'"'"'u/g;s/°/\$\^\\circ\$/g; s//\\textit{/g;s//\\textbf{/g;s/<\/[ib]>/}/g; s//\n\n/g;s/<\/url>/\n<\/url>\n/g;' | \ @@ -121,7 +121,7 @@ function formatify() { sed 's//URL: \\textit\{/g;s/<\/url>/\}/g; s/“/``/g;s/”/'"''"'/g;s///g;s/<\/lang:tex>//g;s/]*>.*<\/lang:[^>]*>//g' elif [ "$1" = "htm" ]; then - sed "s/${NEWLI}${NEWLI}/
${NEWLI}/g;"' + sed "s/&/&/g;s/${NEWLI}${NEWLI}/
${NEWLI}/g;"' s/\([^<]*\)<\/url>/\1<\/a>/g; s///g;s/<\/lang:htm>//g;s/]*>.*<\/lang:[^>]*>//g' fi @@ -278,7 +278,7 @@ function populator() { done fi tag_val="`echo "${!tag_ele}" | sed "s/\$/$NEWLI/g" | tr -d '\n' | sed "s/$NEWLI\$//g" \ - | formatify $frmt`" + | formatify "$frmt"`" debecho " tag_val: $tag_val" # TAG replacement @@ -343,7 +343,7 @@ function populator() { done # TAG replacement tag_val="`echo "${!tag_ele}" | sed "s/\$/$NEWLI/g" | tr -d '\n' | sed "s/$NEWLI\$//g" \ - | formatify $frmt | unsedify`" + | formatify "$frmt" | unsedify`" cat $TMP3FILE | sed "s/#${tag_var}#/$tag_val/g" >$TMP4FILE