Fix some issues found by the shellcheck script, and move an old

file to the attic.
This commit is contained in:
Richard Heck 2017-08-21 17:16:07 -04:00
parent 4c4db93645
commit e6cb0c56ff
5 changed files with 41 additions and 29 deletions

View File

@ -5,6 +5,14 @@
# It also includes several other tests, to make sure the packages # It also includes several other tests, to make sure the packages
# works as it should. # works as it should.
# This has been checked with shellcheck. It complains about a lot
# of missing quotes, but we know, e.g., that $VERSION will not have
# spaces in it. RH chose not to fix that stuff.
#
# That said, the variables $BASE and $SRCDIR will cause problems if
# they have spaces in them, but RH did not fix that, either, since
# he thinks spaces in directory names are just a bad idea.
# A few variables need to be set, here at the top. # A few variables need to be set, here at the top.
# #
# Where we will do our work # Where we will do our work
@ -77,7 +85,7 @@ else
fi fi
LASTNUM=$(echo $VERSION | sed -e 's/.*\.//'); LASTNUM=$(echo $VERSION | sed -e 's/.*\.//');
LAST=$(($LASTNUM - 1)); LAST=$((LASTNUM - 1));
FIRST=$(echo $VERSION | sed -e 's/[0-9]*$//'); FIRST=$(echo $VERSION | sed -e 's/[0-9]*$//');
ORIGINAL=${FIRST}0; ORIGINAL=${FIRST}0;
LAST=$FIRST$LAST; LAST=$FIRST$LAST;
@ -86,14 +94,14 @@ if [ ! -d "$BASE/lyx-patch/" ]; then
mkdir "$BASE/lyx-patch/" || exit 1; mkdir "$BASE/lyx-patch/" || exit 1;
fi fi
if [ ! -d $BASE/lyx-patch/lyx-$LAST ]; then if [ ! -d "$BASE/lyx-patch/lyx-$LAST" ]; then
echo "Can't find directory for last version $LAST."; echo "Can't find directory for last version $LAST.";
echo "See if you can fix this in $BASE/lyx-patch/."; echo "See if you can fix this in $BASE/lyx-patch/.";
echo "Try that, if you like, and then we'll continue."; echo "Try that, if you like, and then we'll continue.";
echo "We'll try to download from the LyX site if that does not work."; echo "We'll try to download from the LyX site if that does not work.";
read; read;
if [ ! -d $BASE/lyx-patch/lyx-$LAST ]; then if [ ! -d "$BASE/lyx-patch/lyx-$LAST" ]; then
echo "Will try to download from LyX site...."; echo "Will try to download from LyX site....";
pushd $BASE/lyx-patch/; pushd $BASE/lyx-patch/;
wget ftp://ftp.lyx.org/pub/lyx/stable/${FIRST}x/lyx-$LAST.tar.gz; wget ftp://ftp.lyx.org/pub/lyx/stable/${FIRST}x/lyx-$LAST.tar.gz;

View File

@ -1,14 +1,17 @@
#!/bin/sh #!/bin/bash
# A script to check whether there have been any string changes. # A script to check whether there have been any string changes.
# If it finds some, it commits the new po files and then updates # If it finds some, it commits the new po files and then updates
# the stats. # the stats.
# We need bash because we use a select loop.
# The script expects an environment variable FARM that will provide # The script expects an environment variable FARM that will provide
# it with the location of the LyX www tree. # it with the location of the LyX www tree.
DEBUG=""; DEBUG="";
COMMIT=""; COMMIT="";
# shellcheck disable=SC2086
while getopts ":cdh" options $ARGS; do while getopts ":cdh" options $ARGS; do
case $options in case $options in
c) COMMIT="TRUE";; c) COMMIT="TRUE";;
@ -38,7 +41,7 @@ fi
# Get us to the root of the tree we are in. # Get us to the root of the tree we are in.
MYDIR=${0%update-po.sh}; MYDIR=${0%update-po.sh};
if [ -n "$MYDIR" ]; then if [ -n "$MYDIR" ]; then
if ! cd $MYDIR; then if ! cd "$MYDIR"; then
echo "Couldn't cd to $MYDIR!"; echo "Couldn't cd to $MYDIR!";
exit 1; exit 1;
fi fi
@ -57,7 +60,7 @@ fi
# Are we in trunk or branch? # Are we in trunk or branch?
TRUNK="TRUE"; TRUNK="TRUE";
if ls status.* 2>/dev/null | grep -q status; then if ls status.* 2>/dev/null; then
TRUNK=""; TRUNK="";
fi fi
@ -80,7 +83,7 @@ fi
# make sure things are clean # make sure things are clean
rm -f i18n.inc; rm -f i18n.inc;
svn revert $FARM/$I18NFILE; svn revert "$FARM/$I18NFILE";
echo Running make i18n.inc... echo Running make i18n.inc...
make i18n.inc >/dev/null 2>&1; make i18n.inc >/dev/null 2>&1;
@ -88,21 +91,21 @@ if [ -n "$TRUNK" ]; then
mv -f i18n.inc i18n_trunk.inc mv -f i18n.inc i18n_trunk.inc
fi fi
if diff -w -q $I18NFILE $FARM/$I18NFILE >/dev/null 2>&1; then if diff -w -q "$I18NFILE $FARM/$I18NFILE" >/dev/null 2>&1; then
echo No string differences found. echo No string differences found.
git checkout *.po; git checkout ./*.po;
exit 0; exit 0;
fi fi
# So there are differences. # So there are differences.
if [ -z "$COMMIT" ]; then if [ -z "$COMMIT" ]; then
echo "Differences found!"; echo "Differences found!";
diff -wu $FARM/$I18NFILE $I18NFILE | less; diff -wu "$FARM/$I18NFILE $I18NFILE" | less;
git checkout *.po *.gmo; git checkout ./*.po ./*.gmo;
exit 0; exit 0;
fi fi
$DEBUG git commit *.po *.gmo -m "Remerge strings."; $DEBUG git commit ./*.po ./*.gmo -m "Remerge strings.";
COMMITS=$(git push -n 2>&1 | tail -n 1 | grep -v "Everything" | sed -e 's/^ *//' -e 's/ .*//'); COMMITS=$(git push -n 2>&1 | tail -n 1 | grep -v "Everything" | sed -e 's/^ *//' -e 's/ .*//');
if [ -z "$COMMITS" ]; then if [ -z "$COMMITS" ]; then
@ -110,6 +113,8 @@ if [ -z "$COMMITS" ]; then
exit 1; exit 1;
fi fi
# there may be multiple commits here
# shellcheck disable=SC2086
git log $COMMITS; git log $COMMITS;
#Do we want to go ahead? #Do we want to go ahead?
@ -127,7 +132,7 @@ done
echo echo
if ! cd $FARM; then if ! cd "$FARM"; then
echo "Unable to cd to $FARM!"; echo "Unable to cd to $FARM!";
exit 1; exit 1;
fi fi
@ -137,8 +142,7 @@ echo Updating the www-user tree...
svn up; svn up;
echo Moving $I18NFILE...; echo Moving $I18NFILE...;
mv $LYXROOT/po/$I18NFILE .; mv "$LYXROOT/po/$I18NFILE" .;
echo Committing...; echo Committing...;
$DEBUG svn commit -m "* $I18NFILE: update stats" $I18NFILE; $DEBUG svn commit -m "* $I18NFILE: update stats" $I18NFILE;

View File

@ -8,9 +8,9 @@ fi
function do_convert { function do_convert {
for i in *; do for i in *; do
if [ ! -f $i ]; then continue; fi if [ ! -f "$i" ]; then continue; fi
cp $i $i.old; cp "$i" "$i.old";
python $lyxdir/lib/scripts/prefs2prefs.py -l <$i.old >$i; python "$lyxdir/lib/scripts/prefs2prefs.py" -l <"$i.old" >"$i";
done done
} }
@ -20,23 +20,23 @@ progloc=$0;
pathto=${progloc%/*}; pathto=${progloc%/*};
# get us into development/tools # get us into development/tools
if [ "$progloc" != "$pathto" ]; then if [ "$progloc" != "$pathto" ]; then
if ! cd $pathto; then if ! cd "$pathto"; then
echo "Couldn't get to development/tools!"; echo "Couldn't get to development/tools!";
exit 1; exit 1;
fi fi
fi fi
curdir=`pwd`; curdir=$(pwd);
lyxdir=${curdir%/development/tools*}; lyxdir=${curdir%/development/tools*};
if ! cd $lyxdir/lib/ui/; then if ! cd "$lyxdir/lib/ui/"; then
echo "Couldn't get to lib/ui!"; echo "Couldn't get to lib/ui!";
exit 1; exit 1;
fi fi
do_convert; do_convert;
if ! cd $lyxdir/lib/bind/; then if ! cd "$lyxdir/lib/bind/"; then
echo "Couldn't get to lib/bind!"; echo "Couldn't get to lib/bind!";
exit 1; exit 1;
fi fi
@ -45,8 +45,8 @@ do_convert;
#now do the subdirectories #now do the subdirectories
for d in *; do for d in *; do
if [ ! -d $d ]; then continue; fi if [ ! -d "$d" ]; then continue; fi
cd $d; pushd "$d";
do_convert; do_convert;
cd ..; popd;
done done

View File

@ -21,14 +21,14 @@ fi
# Get us to the root of the tree we are in. # Get us to the root of the tree we are in.
MYDIR=${0%updatestats.sh}; MYDIR=${0%updatestats.sh};
if [ -n "$MYDIR" ]; then if [ -n "$MYDIR" ]; then
cd $MYDIR; cd "$MYDIR";
fi fi
cd ../../; cd ../../;
LYXROOT=$(pwd); LYXROOT=$(pwd);
# Are we in trunk or branch? # Are we in trunk or branch?
TRUNK="TRUE"; TRUNK="TRUE";
if ls status.* 2>/dev/null | grep -q status; then if ls status.* 2>/dev/null; then
TRUNK=""; TRUNK="";
fi fi
@ -48,7 +48,7 @@ else
I18NFILE=i18n.inc; I18NFILE=i18n.inc;
fi fi
if ! cd $FARM; then if ! cd "$FARM"; then
echo "Unable to cd to $FARM!"; echo "Unable to cd to $FARM!";
exit 1; exit 1;
fi fi
@ -62,7 +62,7 @@ echo Updating the www-user tree...
svn up svn up
echo Copying $I18NFILE...; echo Copying $I18NFILE...;
cp $LYXROOT/po/$I18NFILE .; cp "$LYXROOT/po/$I18NFILE" .;
echo Committing...; echo Committing...;
if [ -z "$GIT" ]; then if [ -z "$GIT" ]; then