1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/tool/ifchange
normal f8d0bdedf1 tool: add descriptions and fix typos
* tool/asm_parse.rb: add description
* tool/change_maker.rb: ditto
* tool/downloader.rb: ditto
* tool/eval.rb: ditto
* tool/expand-config.rb: ditto
* tool/extlibs.rb: ditto
* tool/fake.rb: ditto
* tool/file2lastrev.rb: ditto
* tool/gem-unpack.rb: ditto
* tool/gen_dummy_probes.rb: ditto
* tool/gen_ruby_tapset.rb: ditto
* tool/generic_erb.rb: ditto
* tool/id2token.rb: ditto
* tool/ifchange: ditto
* tool/insns2vm.rb: ditto
* tool/instruction.rb: ditto
* tool/jisx0208.rb: ditto
* tool/merger.rb: ditto
* tool/mkrunnable.rb: ditto
* tool/node_name.rb: ditto
* tool/parse.rb: ditto
* tool/rbinstall.rb: ditto
* tool/rbuninstall.rb: ditto
* tool/rmdirs: ditto
* tool/runruby.rb: ditto
* tool/strip-rdoc.rb: ditto
* tool/vcs.rb: ditto
* tool/vtlh.rb: ditto
* tool/ytab.sed: ditto
* tool/enc-unicode.rb: fix typo
* tool/mk_call_iseq_optimized.rb: ditto
* tool/update-deps: ditto
  [ruby-core:76215] [Bug #12539]
  by Noah Gibbs <the.codefolio.guy@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-02 21:01:04 +00:00

87 lines
1.9 KiB
Bash
Executable file
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
# usage: ifchange target temporary
# Used in generating revision.h via Makefiles.
set -e
timestamp=
keepsuffix=
empty=
color=auto
until [ $# -eq 0 ]; do
case "$1" in
--timestamp)
timestamp=.
;;
--timestamp=*)
timestamp=`expr \( "$1" : '[^=]*=\(.*\)' \)`
;;
--keep)
keepsuffix=.old
;;
--keep=*)
keepsuffix=`expr \( "$1" : '[^=]*=\(.*\)' \)`
;;
--empty)
empty=yes
;;
--color)
color=always
;;
--color=*)
color=`expr \( "$1" : '[^=]*=\(.*\)' \)`
;;
*)
break
;;
esac
shift
done
target="$1"
temp="$2"
if [ "$temp" = - ]; then
temp="tmpdata$$.tmp~"
cat > "$temp"
trap 'rm -f "$temp"' 0
fi
msg_begin= msg_unchanged= msg_updated= msg_reset=
if [ "$color" = always -o \( "$color" = auto -a -t 1 \) ]; then
msg_begin="["
case "`tput smso 2>/dev/null`" in
"$msg_begin"*m)
if [ ${TEST_COLORS:+set} ]; then
msg_unchanged=`expr ":$TEST_COLORS:" : ".*:pass=\([^:]*\):"` || :
msg_updated=`expr ":$TEST_COLORS:" : ".*:fail=\([^:]*\):"` || :
fi
msg_unchanged="${msg_begin}${msg_unchanged:-32;1}m"
msg_updated="${msg_begin}${msg_updated:-31;1}m"
msg_reset="${msg_begin}m"
;;
esac
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"${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
if [ x"$targetdir" = x ]; then
timestamp=.time."$target"
else
timestamp="$targetdir"/.time.`basename "$target"`
fi
fi
: > "$timestamp"
fi