]> git.lyx.org Git - lyx.git/blob - development/tools/mkdoclinks.sh
Check if we are on column 0 for special case
[lyx.git] / development / tools / mkdoclinks.sh
1 #! /bin/sh
2
3 # This script makes a bunch of symbolic links from the current directory
4 # to the one containing the LyX documentation.
5
6 USAGE () {
7         echo Usage: $0 dir_where_the_docs_are_found
8         exit 1
9 }
10
11 if [ $# -ne 1 ]; then
12         USAGE
13 fi
14
15 DIR=$1
16
17 if [ ! -d ${DIR} ]; then
18         USAGE
19 fi
20
21 FILES=`ls ${DIR}/*.*`
22
23 N_LYXFILES=`echo "${FILES}" | grep ".lyx" | wc -l`
24
25 if [ ${N_LYXFILES} -eq 0 ]; then
26         echo ${DIR} contains NO lyx files!
27         exit 1
28 fi
29
30 EXAMPLE_FILE=`echo "${FILES}" | grep ".lyx" | sed -e '2,$d'`
31 PARSABLEDIR=`echo ${DIR} | sed 's/\//\\\\\//g'`
32 EXAMPLE_FILE=`echo ${EXAMPLE_FILE} | sed "s/${PARSABLEDIR}\///"`
33
34 echo ${DIR} contains ${N_LYXFILES} .lyx files, an example being ${EXAMPLE_FILE}
35 echo
36 echo "Would you like to generate links to the files in this dir? (Y/N) >N<"
37 read ANSWER
38
39 if [ "${ANSWER}" != "y" -a "${ANSWER}" != "Y" ]; then
40         exit 0
41 fi
42
43 echo
44 echo "Would you like these file names in the .cvsignore file? (Y/N) >N<"
45 read ANSWER
46
47 CVSIGNORE=0
48 if [ "${ANSWER}" = "y" -o "${ANSWER}" = "Y" ]; then
49         CVSIGNORE=1
50 fi
51
52 # Keep the original .cvsignore file safe
53 if [ ${CVSIGNORE} -eq 1 ]; then
54         if [ -r .cvsignore ]; then
55                 if [ -r .cvsignore-safe ]; then
56                         cp .cvsignore-safe .cvsignore
57                 else
58                         cp .cvsignore .cvsignore-safe
59                 fi
60         fi
61         echo .cvsignore-safe > .cvsignore
62         echo '*.lyx' >> .cvsignore
63         echo '*.eps' >> .cvsignore
64 fi
65
66 for FILE in ${FILES}
67 do
68         DESTFILE=`echo ${FILE} | sed "s/${PARSABLEDIR}\///"`
69         ln -fs ${FILE} ${DESTFILE}
70 done