2 # Yes, this intends to be a true POSIX script file.
7 # Parse the tools' paths configuration
12 Usage: ${myname} <dir> <base> <inc> [sed_re]
13 Will renumber all patches found in 'dir', starting at 'base', and with
14 an increment of 'inc'.
15 If 'sed_re' is given, it is interpreted as a valid sed expression, and
16 it will be applied to the patch name.
17 If the environment variable FAKE is set to 'y', then the command will
18 only be printed, and not executed (so you can check beforehand).
20 patch-renumber.sh patches/gcc/4.3.1 100 10
21 patch-renumber.sh patches/gcc/4.2.4 100 10 's/(all[_-])*(gcc[-_])*//;'
25 [ $# -lt 3 -o $# -gt 4 ] && { doUsage; exit 1; }
26 [ -d "${1}" ] || { doUsage; exit 1; }
33 case "$(LC_ALL=C hg id "${dir}" 2>/dev/null)" in
38 if [ "${FAKE}" = "y" ]; then
42 for p in "${dir}"/*.patch*; do
43 [ -e "${p}" ] || { echo "No such file '${p}'"; exit 1; }
44 newname="$(printf "%03d-%s" \
47 |"${sed}" -r -e 's/^[[:digit:]]+[-_]//' \
51 [ "${p}" = "${dir}/${newname}" ] || ${CMD} mv -v "${p}" "${dir}/${newname}"