aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-09 06:31:54 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-09 06:31:54 +0000
commitba6f4f0a2eabb862af35b6a4951e6100d5123231 (patch)
tree860de5b4c611aa8261943ea0f66a455ee43226bc
parent0299386b12180ea4bb9bc6d2844fcb1eb5fb54ca (diff)
downloadruby-ba6f4f0a2eabb862af35b6a4951e6100d5123231.tar.gz
ifchange: make target directory
* tool/ifchange: make target directory if it does not exist with its parent directories. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rwxr-xr-xtool/ifchange18
2 files changed, 13 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 2b0aa0d57c..3cfc64c393 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
-Thu Jun 9 15:31:09 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Jun 9 15:31:52 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * tool/ifchange: make target directory if it does not exist with
+ its parent directories.
* win32/ifchange.bat: drop support for command.com used on old
systems.
diff --git a/tool/ifchange b/tool/ifchange
index 08aaba570c..8603306cdb 100755
--- a/tool/ifchange
+++ b/tool/ifchange
@@ -61,25 +61,25 @@ if [ "$color" = always -o \( "$color" = auto -a -t 1 \) ]; then
unset msg_begin
fi
+targetdir=
+case "$target" in */*) targetdir=`dirname "$target"`;; esac
if [ -f "$target" -a ! -${empty:+f}${empty:-s} "$temp" ] || cmp "$target" "$temp" >/dev/null 2>&1; then
echo "$target ${msg_unchanged}unchanged${msg_reset}"
rm -f "$temp"
else
echo "$target ${msg_updated}updated${msg_reset}"
- [ x"${keepsuffix}" = x ] || mv -f "$target" "${target}${keepsuffix}"
+ [ x"${targetdir}" = x -o -d "${targetdir}" ] || mkdir -p "${targetdir}"
+ [ x"${keepsuffix}" != x -a -f "$target" ] && mv -f "$target" "${target}${keepsuffix}"
mv -f "$temp" "$target"
fi
if [ -n "${timestamp}" ]; then
if [ x"${timestamp}" = x. ]; then
- case "$target" in
- */*)
- timestamp=`dirname "$target"`/.time.`basename "$target"`
- ;;
- *)
- timestamp=.time."$target"
- ;;
- esac
+ if [ x"$targetdir" = x. ]; then
+ timestamp=.time."$target"
+ else
+ timestamp="$targetdir"/.time.`basename "$target"`
+ fi
fi
: > "$timestamp"
fi