summaryrefslogtreecommitdiff
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
commit9403716fb093e1a6e1c3dfbfb32561dad9d84198 (patch)
tree860de5b4c611aa8261943ea0f66a455ee43226bc
parentf4d18f524cfe6f94895d1af6325fd5d3fd3cd9c3 (diff)
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 2b0aa0d57c8..3cfc64c393f 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 08aaba570c8..8603306cdb3 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