Installer: Early check whether the installation directory is writable
[msysgit.git] / bin / move-wiki.sh
blob530bc3048fd88572bf6f7572f954d5d92e8eb97b
1 #!/bin/sh
3 case $(uname -s) in
4 MINGW*)
5 EDITOR=wordpad
6 START=start
7 ;;
8 Linux)
9 EDITOR=gedit
10 START=xdg-open
12 esac
14 OLDWIKISVN=http://msysgit.googlecode.com/svn/wiki
15 NEWWIKI=http://git.wiki.kernel.org/index.php
16 NAMESPACE=MSysGit
18 transform () {
19 perl -e 'while (<>) {
20 if ($_ eq "{{{\n") {
21 print "<code>\n";
22 while (<>) {
23 last if ($_ eq "}}}\n" || $_ eq "}}}");
24 print $_;
26 print "</code>\n";
27 next;
29 s/^#.*/<!-- $& -->/;
30 s/{{{(.*?)}}}/<code>$1<\/code>/g;
31 s/`(.*?)`/<code>$1<\/code>/g;
32 s/_(.*?)_/'\'''\''$1'\'''\''/g;
33 s/\*(.*?)\*/'\'''\'''\''$1'\'''\'''\''/g;
34 s/(?<=\s)!([A-Z])/$1/g;
35 s/(?<!\[)\[(?![a-z]*:)([^\] ]+) +([^\]]+)\]/[[MSysGit:$1|$2]]/g;
36 s/(?<!\[)\[(?![a-z]*:)([^\] ]+)\]/[[MSysGit:$1|$1]]/g;
37 s/^ \*/*/;
38 s/(\s)_(\S[^_]*\S)_(\s)/$1<u>$2<\/u>$3/g;
39 print $_;
41 print "\n[[Category:MSysGit]]\n";
45 download () {
46 curl $OLDWIKISVN/"$1".wiki
49 download_index () {
50 curl $OLDWIKISVN/ |
51 sed -n 's/.*>\([^<]*\)\.wiki<.*/\1/p'
54 action () {
55 download "$1" > /tmp/"$1".old &&
56 transform < /tmp/"$1".old > /tmp/"$1".wiki &&
57 $START $NEWWIKI?title="$NAMESPACE:$1&action=edit" &&
58 $EDITOR /tmp/"$1".wiki &&
59 rm /tmp/"$1".old /tmp/"$1".wiki
62 test $# = 0 && set $(download_index)
64 for arg
66 action $arg
67 done