Fix bashisms in scripts
[scilab.git] / scilab / modules / helptools / src / script / dispatchHelp.sh
1 #!/bin/sh
2
3 # English is the reference. Update all other languages to put them at the right
4 # place.
5
6 if test -z "$SCI"; then
7         echo "Please define the variable SCI"
8         exit 254
9 fi
10
11 REFERENCE_LANG=en_US
12 LANGS="ja_JP fr_FR pt_BR"
13
14 ENGLISH_FILES=$(find modules/ -iname '*.xml'|grep "/help/$REFERENCE_LANG")
15
16 for f in $ENGLISH_FILES; do
17     FILENAME=$(basename $f)
18     DIRNAME=$(dirname $f)
19     MODULENAME=$(echo $f|awk -F '/' '{print $1"/"$2}')
20
21     # Check if the file already exists in other langs
22     for l in $LANGS; do
23         fTranslated=$(echo $f|sed -e "s|$REFERENCE_LANG|$l|")
24
25         if test ! -f $fTranslated; then
26             # File not found. However, it might not have been translated
27             # Look if it the case or not
28
29             # File found but at the wrong place
30             FOUNDFILE=$(find $MODULENAME -name $FILENAME|grep $l)
31             if test "$FOUNDFILE" != ""; then
32                 # File found.
33                 TARGET=$(echo $DIRNAME|sed -e "s|$REFERENCE_LANG|$l|")
34                 if test ! -d $TARGET; then
35                     echo "Creation of $TARGET"
36                     mkdir $TARGET
37                 fi
38                 echo "mv $FOUNDFILE $TARGET"
39                 mv $FOUNDFILE $TARGET
40             fi
41             
42
43         fi
44     done
45 done