Fix minimal/do and tests when built in a path containing spaces.

Basically all just missing quotes around shell strings that use $PWD.
Most paths inside a project, since redo uses relative paths, only need
to worry when project-internal directories or filenames have spaces in
them.

Reported-by: Jeff Stearns <jeff.stearns@gmail.com>
This commit is contained in:
Avery Pennarun 2018-12-11 01:19:58 +00:00
commit 474e12eed8
6 changed files with 19 additions and 17 deletions

View file

@ -19,24 +19,25 @@ read py <redo/whichpython
echo "Installing to: $DESTDIR$PREFIX"
# make dirs
$INSTALL -d $MANDIR/man1 $DOCDIR $BINDIR $LIBDIR $LIBDIR/version
"$INSTALL" -d "$MANDIR/man1" "$DOCDIR" "$BINDIR" \
"$LIBDIR" "$LIBDIR/version"
# docs
for d in docs/*.1; do
[ "$d" = "docs/*.1" ] && continue
$INSTALL -m 0644 $d $MANDIR/man1
"$INSTALL" -m 0644 $d "$MANDIR/man1"
done
$INSTALL -m 0644 README.md $DOCDIR
"$INSTALL" -m 0644 README.md "$DOCDIR"
# .py files (precompiled to .pyc files for speed)
$INSTALL -m 0644 redo/*.py $LIBDIR/
$INSTALL -m 0644 redo/version/*.py $LIBDIR/version/
$py -mcompileall $LIBDIR
"$INSTALL" -m 0644 redo/*.py "$LIBDIR/"
"$INSTALL" -m 0644 redo/version/*.py "$LIBDIR/version/"
"$py" -mcompileall "$LIBDIR"
# It's important for the file to actually be named 'sh'. Some shells (like
# bash and zsh) only go into POSIX-compatible mode if they have that name.
cp -R redo/sh $LIBDIR/sh
cp -R redo/sh "$LIBDIR/sh"
# binaries
bins=$(ls bin/redo* | grep '^bin/redo[-a-z]*$')
$INSTALL -m 0755 $bins $BINDIR/
"$INSTALL" -m 0755 $bins "$BINDIR/"

View file

@ -4,7 +4,7 @@
# For the full version, visit http://github.com/apenwarr/redo
#
# The author disclaims copyright to this source file and hereby places it in
# the public domain. (2010 12 14; updated 2018 12 04)
# the public domain. (2010 12 14; updated 2018 12 11)
#
USAGE="
usage: do [-d] [-x] [-v] [-c] <targets...>
@ -44,7 +44,8 @@ dirname()
)
_dirsplit "$0"
export REDO=$(cd "${_dirsplit_dir:-.}" && echo "$PWD/$_dirsplit_base")
REDO=$(cd "${_dirsplit_dir:-.}" && echo "$PWD/$_dirsplit_base")
export REDO
_cmd=$_dirsplit_base
DO_TOP=
@ -76,7 +77,7 @@ if [ -z "$DO_BUILT" -a "$_cmd" != "redo-whichdo" ]; then
if [ "$#" -eq 0 ] && [ "$_cmd" = "do" -o "$_cmd" = "redo" ]; then
set all # only toplevel redo has a default target
fi
export DO_BUILT=$PWD/.do_built
export DO_BUILT="$PWD/.do_built"
if [ -z "$_do_opt_clean" -a -e "$DO_BUILT" ]; then
echo "do: Incremental mode. Use -c for clean rebuild." >&2
fi
@ -89,7 +90,7 @@ if [ -z "$DO_BUILT" -a "$_cmd" != "redo-whichdo" ]; then
xargs -0 rm -f 2>/dev/null
mv "$DO_BUILT.new" "$DO_BUILT"
DO_PATH=$DO_BUILT.dir
export PATH=$DO_PATH:$PATH
export PATH="$DO_PATH:$PATH"
rm -rf "$DO_PATH"
mkdir "$DO_PATH"
for d in redo redo-ifchange redo-whichdo; do

View file

@ -102,8 +102,8 @@ check_s "" "$_dirsplit_base"
SECTION _relpath
check "a/b/c" _relpath $PWD/a/b/c
check "../a/b/c" _relpath $PWD/../a/b/c
check "a/b/c" _relpath "$PWD/a/b/c"
check "../a/b/c" _relpath "$PWD/../a/b/c"
check "" _relpath "$PWD"
(cd / && check "a/b/c" _relpath a/b/c)
(cd / && check "a/b/c" _relpath /a/b/c)

View file

@ -25,7 +25,7 @@ for sh in dash /usr/xpg4/bin/sh ash posh mksh ksh ksh88 ksh93 pdksh \
SH=$PWD/$1.new/sh
set +e
( cd ../t && $SH shelltest.od ) >shelltest.tmp 2>&1
( cd ../t && "$SH" shelltest.od ) >shelltest.tmp 2>&1
RV=$?
set -e

View file

@ -2,6 +2,6 @@ printf x >>a.ran
rm -f dir/$2.1 $2.2 $2.3 $2.final
echo foo >$2.final
ln -s $2.final $2.3
ln -s $PWD/$2.3 $2.2
ln -s "$PWD/$2.3" $2.2
ln -s ../$2.2 dir/$2.1
ln -s dir/$2.1 $3

View file

@ -1,2 +1,2 @@
rm -rf test.tmp
DESTDIR=$PWD/test.tmp redo ../../install >install.log 2>&1
DESTDIR="$PWD/test.tmp" redo ../../install >install.log 2>&1