Re: help with bash script to translate @ref{} items in translated manuals
Il giorno ven 21 apr 2017 alle 7:08, Federico Bruni ha scritto: I guess I'll have to revert to my almost manual replacement I've used so far. Or I may try a different approach and script a replacement from a file like: @ref{Different editions from one source},@ref{Edizioni diverse da un unico sorgente} @ref{Dimensions},@ref{Dimensioni} @ref{Direction and placement},@ref{Direzione e posizionamento} that replace first instance of @ref with the second instance (after the comma) ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: help with bash script to translate @ref{} items in translated manuals
Il giorno gio 20 apr 2017 alle 11:22, k...@aspodata.se ha scritto: Frederico Bruni: ... Enter Documentation/it/notation and run this: #!/bin/bash LIST="$(grep -oh -e @ref{.*} *.itely | sort -u)" for i in $LIST; do echo $i #echo -n "Replace" $i "with the translated node: " #read NODE #if $NODE=""; then exit #else #sed "s|$i|$NODE|g" *.itely #fi done This doesn't work: $ LIST="$(grep -oh -e @ref{.*} *.itely | sort -u)" $ echo $LIST This is better but messes with newlines: $ LIST=$(grep -oh -e "@ref{.*}" *.itely | sort -u) $ echo $LIST @ref{Accidentals} @ref{Align} @ref{Aligning lyrics to a melody [...] The "for i in $LIST" also messes with newlines. This will rid you of the newline problem: $ grep -oh -e "@ref{.*}" *.itely | sort -u | while read i; do echo $i; done @ref{Accidentals} @ref{Align} ... but now "read NODE" won't read from script stdin. Trying with /dev/stdin doesn't help since stdin is from the pipe, not the script stdin. yes, this is a problem... $ grep -oh -e "@ref{.*}" *.itely | sort -u | while read i; do echo $i; read NODE < /dev/stdin; echo $b; break; done @ref{Accidentals} @ref{Align} you culd solve that with arrays: $ cat tt #!/bin/sh # for some reason mapfile doesnt work on pipes, hence the tmpfile grep -oh -e "@ref{.*}" *.itely | sort -u > tmpfile mapfile -t org < tmpfile len=${#org[@]} for (( ix=0; ix < $len; ix++ )) do read NODE printf "%4d: %s %s\n" $ix "${org[ix]}" "$NODE" done Unfortunately this script hangs forever. I guess I'll have to revert to my almost manual replacement I've used so far. $ ./tt | head -5 a d 0: @ref{Accidentals} a d cd g 1: @ref{Align} cd g gv 2: @ref{Aligning lyrics to a melody} gv xcvb rge 3: @ref{Aligning objects} xcvb rge rtdfg gr 4: @ref{Ambitus} rtdfg gr 2 $ you could also do the for loop like: for i in "${org[@]}" do read NODE echo $i $NODE done Regards, /Karl Hammar --- Aspö Data Lilla Aspö 148 S-742 94 Östhammar Sweden +46 173 140 57 ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Fix not scaling stem in note-by-number-markup (issue 324780043 by thomasmorle...@gmail.com)
LGTM. https://codereview.appspot.com/324780043/ ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: help with bash script to translate @ref{} items in translated manuals
Hi All, All good answers, but so much easier in perl! Andrew ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: help with bash script to translate @ref{} items in translated manuals
Frederico Bruni: ... > Enter Documentation/it/notation and run this: > > #!/bin/bash > LIST="$(grep -oh -e @ref{.*} *.itely | sort -u)" > for i in $LIST; do > echo $i > #echo -n "Replace" $i "with the translated node: " > #read NODE > #if $NODE=""; then exit > #else > #sed "s|$i|$NODE|g" *.itely > #fi > done This doesn't work: $ LIST="$(grep -oh -e @ref{.*} *.itely | sort -u)" $ echo $LIST This is better but messes with newlines: $ LIST=$(grep -oh -e "@ref{.*}" *.itely | sort -u) $ echo $LIST @ref{Accidentals} @ref{Align} @ref{Aligning lyrics to a melody [...] The "for i in $LIST" also messes with newlines. This will rid you of the newline problem: $ grep -oh -e "@ref{.*}" *.itely | sort -u | while read i; do echo $i; done @ref{Accidentals} @ref{Align} ... but now "read NODE" won't read from script stdin. Trying with /dev/stdin doesn't help since stdin is from the pipe, not the script stdin. $ grep -oh -e "@ref{.*}" *.itely | sort -u | > while read i; do echo $i; read NODE < /dev/stdin; echo $b; break; done @ref{Accidentals} @ref{Align} you culd solve that with arrays: $ cat tt #!/bin/sh # for some reason mapfile doesnt work on pipes, hence the tmpfile grep -oh -e "@ref{.*}" *.itely | sort -u > tmpfile mapfile -t org < tmpfile len=${#org[@]} for (( ix=0; ix < $len; ix++ )) do read NODE printf "%4d: %s %s\n" $ix "${org[ix]}" "$NODE" done $ ./tt | head -5 a d 0: @ref{Accidentals} a d cd g 1: @ref{Align} cd g gv 2: @ref{Aligning lyrics to a melody} gv xcvb rge 3: @ref{Aligning objects} xcvb rge rtdfg gr 4: @ref{Ambitus} rtdfg gr 2 $ you could also do the for loop like: for i in "${org[@]}" do read NODE echo $i $NODE done Regards, /Karl Hammar --- Aspö Data Lilla Aspö 148 S-742 94 Östhammar Sweden +46 173 140 57 ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: help with bash script to translate @ref{} items in translated manuals
Federico Bruni writes: > #!/bin/bash > LIST="$(grep -oh -e @ref{.*} *.itely | sort -u)" > for i in $LIST; do This splits $LIST at separators contained in the shell variable IFS . One can temporarily override it to just split on newlines, but it is more straightforward to write grep -oh -e @ref{.*} *.itely | sort -u | while read i; do rather than tamper with shell syntax temporarily. >echo $i > #echo -n "Replace" $i "with the translated node: " > #read NODE > #if $NODE=""; then exit > #else > #sed "s|$i|$NODE|g" *.itely > #fi > done > > You'll get something like: > > @ref{Tuplets} > @ref{Turkish > classical > music} > @ref{Typesetting > Gregorian > chant} > > > The problem is the space character, which is not matched in the bash > script. > Why? > > Thanks in advance > Federico > -- David Kastrup ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel