annotate src/vimtutor @ 676:9cdb8018cdf1

updated for version 7.0202
author vimboss
date Mon, 20 Feb 2006 21:28:49 +0000
parents 3fc0f57ecb91
children 469c42f90fda
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 #! /bin/sh
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 # Start Vim on a copy of the tutor file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 # Usage: vimtutor [xx], where xx is a language code like "es" or "nl".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 # When an argument is given, it tries loading that tutor.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 # When this fails or no argument was given, it tries using 'v:lang'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 # When that also fails, it uses the English version.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 xx=$1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 export xx
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 # We need a temp file for the copy. First try using a standard command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 tmp="${TMPDIR-/tmp}"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 TUTORCOPY=`mktemp $tmp/tutorXXXXXX || tempfile -p tutor || echo none`
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 # If the standard commands failed then create a directory to put the copy in.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 # That is a secure way to make a temp file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 if test "$TUTORCOPY" = none; then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 tmpdir=$tmp/vimtutor$$
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 OLD_UMASK=`umask`
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 umask 077
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 getout=no
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 mkdir $tmpdir || getout=yes
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 umask $OLD_UMASK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 if test $getout = yes; then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 echo "Could not create directory for tutor copy, exiting."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 exit 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 fi
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 TUTORCOPY=$tmpdir/tutorcopy
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 touch $TUTORCOPY
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 TODELETE=$tmpdir
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 TODELETE=$TUTORCOPY
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 fi
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 export TUTORCOPY
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 # remove the copy of the tutor on exit
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 trap "rm -rf $TODELETE" 0 1 2 3 9 11 13 15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 # Vim could be called "vim" or "vi". Also check for "vim6", for people who
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 # have Vim 5.x installed as "vim" and Vim 6.0 as "vim6".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 testvim=`which vim6 2>/dev/null`
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 if test -f "$testvim"; then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 VIM=vim6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 testvim=`which vim`
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 if test -f "$testvim"; then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 VIM=vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 VIM=vi
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 fi
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 fi
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 # Use Vim to copy the tutor, it knows the value of $VIMRUNTIME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 # The script tutor.vim tells Vim which file to copy
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 $VIM -u NONE -c 'so $VIMRUNTIME/tutor/tutor.vim'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 # Start vim without any .vimrc, set 'nocompatible'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 $VIM -u NONE -c "set nocp" $TUTORCOPY