diff options
| author | Marc Vertes <mvertes@free.fr> | 2021-06-20 14:33:05 +0200 |
|---|---|---|
| committer | Marc Vertes <mvertes@free.fr> | 2021-06-20 14:33:05 +0200 |
| commit | 1433c15716d0da97d54d39f7397b80654ce10415 (patch) | |
| tree | 3fd8b1c8e84e2e3306a974db16336d91b7f6fee8 /bin | |
| parent | 6f40c5ba8549a66bd2b9ab449f57a574f0c2e905 (diff) | |
vimki: fix rename
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/vimki | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -5,8 +5,16 @@ # rename changes the link name and propagates the change in the wiki rename1() { gawk -v old="$1" -v new="$2" -v IGNORECASE=1 ' + { + gsub("[[]" old "[]]", "[" new "]") + print + } + ' "$3" +} + +link2rx() { + gawk -v rx="$1" -v IGNORECASE=1 ' BEGIN { - rx = old gsub(/_/, "\\W+", rx) gsub(/a/, "[aåäáàâã]", rx) gsub(/c/, "[cç]", rx) @@ -16,12 +24,8 @@ rename1() { gsub(/u/, "[uùûüú]", rx) gsub(/y/, "[yÿ]", rx) gsub(/n/, "[nñ]", rx) - } - { - gsub("[[]" rx "[]]", "[" new "]") - print - } - ' "$3" + print rx + }' } #shellcheck disable=SC2020 @@ -34,9 +38,10 @@ linkfile() { } rename() { + rx=$(link2rx "$1") for f in *.md; do [ "$(head -c 8 "$f")" = VimCrypt ] && continue - rename1 "$1" "$2" "$f" > "$f.$$" && mv "$f.$$" "$f" + rename1 "$rx" "$2" "$f" > "$f.$$" && mv "$f.$$" "$f" done oldf="$(linkfile "$1").md" [ -f "$oldf" ] && mv "$oldf" "$(linkfile "$2").md" |
