Commit df59d2a9 authored by Lionel Elie Mamane's avatar Lionel Elie Mamane

c2btools scripts: protect _everything_ against filenames with spaces

parent 0a182df4
......@@ -32,7 +32,7 @@ bibtexCmd=bibtex
#-------------------------------------------------------------------------------
# Immediately check that the needed programs are there:
${latexCmd} --version > /dev/null 2>&1
"${latexCmd}" --version > /dev/null 2>&1
if [ "$?" != "0" ]
then
......@@ -41,7 +41,7 @@ then
exit 1
fi
${bibtexCmd} --version > /dev/null 2>&1
"${bibtexCmd}" --version > /dev/null 2>&1
if [ "$?" != "0" ]
then
......@@ -54,7 +54,7 @@ fi
if [ "x${dvi2pdfCmd}" != "x" ]
then
${dvi2pdfCmd} --version | head -n2 | grep dvipdfm > /dev/null 2>&1
"${dvi2pdfCmd}" --version | head -n2 | grep dvipdfm > /dev/null 2>&1
if [ "$?" != "0" ]
then
echo "Program ${dvi2pdfCmd} (LaTeX software) is required."
......@@ -91,7 +91,7 @@ bib="$1"
pdf="$2"
work_dir="$PWD"
cat > $tmp_dir/c2b_tmp.tex <<EOF
cat > "${tmp_dir}"/c2b_tmp.tex <<EOF
\documentclass[a4paper,10pt]{article}
%\documentclass[letterpaper,10pt]{article}
\pagenumbering{roman}
......@@ -112,26 +112,26 @@ cat > $tmp_dir/c2b_tmp.tex <<EOF
\end{document}
EOF
cp "$bib" $tmp_dir/c2b_tmp.bib
cp "$bib" "${tmp_dir}"/c2b_tmp.bib
# LaTeX procedure (Modify accordingly)
cd $tmp_dir
cd "${tmp_dir}"
# There might be bibliography errors, do not stop.
set +e
${latexCmd} $latex_flags c2b_tmp >& /dev/null
${bibtexCmd} c2b_tmp
${latexCmd} $latex_flags c2b_tmp >& /dev/null
${latexCmd} $latex_flags c2b_tmp
"${latexCmd}" $latex_flags c2b_tmp >& /dev/null
"${bibtexCmd}" c2b_tmp
"${latexCmd}" $latex_flags c2b_tmp >& /dev/null
"${latexCmd}" $latex_flags c2b_tmp
if [ "x${dvi2pdfCmd}" != "x" ]
then
${dvi2pdfCmd} c2b_tmp >& /dev/null
"${dvi2pdfCmd}" c2b_tmp >& /dev/null
fi
# Make sure we trap errors.
set -e
# Clean up
cd $work_dir
cp $tmp_dir/c2b_tmp.pdf "$pdf"
rm -rf $tmp_dir
cd "${work_dir}"
cp "${tmp_dir}"/c2b_tmp.pdf "$pdf"
rm -rf "${tmp_dir}"
echo "$0 ended."
......@@ -37,7 +37,7 @@ xml2bib_flags="-sd -b"
#-------------------------------------------------------------------------------
# Immediately check that the needed programs are there:
$isi2xml --version > /dev/null 2>&1
"${isi2xml}" --version > /dev/null 2>&1
if [ "$?" != "0" ]
then
......@@ -47,7 +47,7 @@ then
exit 1
fi
$xml2bib --version > /dev/null 2>&1
"${xml2bib}" --version > /dev/null 2>&1
if [ "$?" != "0" ]
then
......@@ -85,17 +85,17 @@ bib="$2"
work_dir="$PWD"
# Preparing temporary files
cp "$isi" $tmp_dir/c2b_tmp.isi
cp "$isi" $tmp_dir/c2b_tmp.bib
cp "$isi" "${tmp_dir}"/c2b_tmp.isi
cp "$isi" "${tmp_dir}"/c2b_tmp.bib
# bibutils procedure
cd $tmp_dir
$isi2xml $isi2xml_flags c2b_tmp.isi > c2b_tmp.xml
$xml2bib $xml2bib_flags c2b_tmp.xml | sed 's%^ISSUE=%NUMBER=%g' > c2b_tmp.bib
cd "${tmp_dir}"
"${isi2xml}" $isi2xml_flags c2b_tmp.isi > c2b_tmp.xml
"${xml2bib}" $xml2bib_flags c2b_tmp.xml | sed 's%^ISSUE=%NUMBER=%g' > c2b_tmp.bib
# Clean up
cd $work_dir
cp $tmp_dir/c2b_tmp.bib "$bib"
rm -rf $tmp_dir
cd "${work_dir}"
cp "${tmp_dir}"/c2b_tmp.bib "$bib"
rm -rf "${tmp_dir}"
echo ""
echo "$0 ended."
......@@ -31,7 +31,7 @@ xml2bib_flags="-sd -b"
#-------------------------------------------------------------------------------
# Immediately check that the needed programs are there:
$med2xml --version > /dev/null 2>&1
"${med2xml}" --version > /dev/null 2>&1
if [ "$?" != "0" ]
then
......@@ -41,7 +41,7 @@ then
exit 1
fi
$xml2bib --version > /dev/null 2>&1
"${xml2bib}" --version > /dev/null 2>&1
if [ "$?" != "0" ]
then
......@@ -79,17 +79,17 @@ bib="$2"
work_dir="$PWD"
# Preparing temporary files
cp "$med" $tmp_dir/c2b_tmp.med
cp "$med" $tmp_dir/c2b_tmp.bib
cp "$med" "${tmp_dir}"/c2b_tmp.med
cp "$med" "${tmp_dir}"/c2b_tmp.bib
# bibutils procedure
cd $tmp_dir
$med2xml $med2xml_flags c2b_tmp.med > c2b_tmp.xml
$xml2bib $xml2bib_flags c2b_tmp.xml | sed 's%^ISSUE=%NUMBER=%g' > c2b_tmp.bib
cd "${tmp_dir}"
"${med2xml}" $med2xml_flags c2b_tmp.med > c2b_tmp.xml
"${xml2bib}" $xml2bib_flags c2b_tmp.xml | sed 's%^ISSUE=%NUMBER=%g' > c2b_tmp.bib
# Clean up
cd $work_dir
cp $tmp_dir/c2b_tmp.bib "$bib"
rm -rf $tmp_dir
cd "${work_dir}"
cp "${tmp_dir}"/c2b_tmp.bib "$bib"
rm -rf "${tmp_dir}"
echo ""
echo "$0 ended."
......@@ -37,7 +37,7 @@ xml2bib_flags="-sd -b"
#-------------------------------------------------------------------------------
# Immediately check that the needed programs are there:
$ris2xml --version > /dev/null 2>&1
"${ris2xml}" --version > /dev/null 2>&1
if [ "$?" != "0" ]
then
......@@ -47,7 +47,7 @@ then
exit 1
fi
$xml2bib --version > /dev/null 2>&1
"${xml2bib}" --version > /dev/null 2>&1
if [ "$?" != "0" ]
then
......@@ -85,17 +85,17 @@ bib="$2"
work_dir="$PWD"
# Preparing temporary files
cp "$ris" $tmp_dir/c2b_tmp.ris
cp "$ris" $tmp_dir/c2b_tmp.bib
cp "$ris" "${tmp_dir}"/c2b_tmp.ris
cp "$ris" "${tmp_dir}"/c2b_tmp.bib
# bibutils procedure
cd $tmp_dir
$ris2xml $ris2xml_flags c2b_tmp.ris > c2b_tmp.xml
$xml2bib $xml2bib_flags c2b_tmp.xml | sed 's%^ISSUE=%NUMBER=%g' > c2b_tmp.bib
cd "${tmp_dir}"
"${ris2xml}" ${ris2xml_flags} c2b_tmp.ris > c2b_tmp.xml
"${xml2bib}" ${xml2bib_flags} c2b_tmp.xml | sed 's%^ISSUE=%NUMBER=%g' > c2b_tmp.bib
# Clean up
cd $work_dir
cp $tmp_dir/c2b_tmp.bib "$bib"
rm -rf $tmp_dir
cd "${work_dir}"
cp "${tmp_dir}"/c2b_tmp.bib "$bib"
rm -rf "${tmp_dir}"
echo ""
echo "$0 ended."
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment