vim-patch: Replace shell variables in printf with formatted args

This ensures that special characters in the variables are not
interpreted as escapes/format characters in the printf string, as was
seen with upstream patch 8.0.0615.

    $ ./scripts/vim-patch.sh -p 8.0.0615
    Updating Vim sources: /$HOME/src/neovim/.vim-src
    ✔ Updated Vim sources.
    ✔ Found Vim revision 'bf15b8d78b22661db8b19d662b62bb9a061cdd37'.
    Creating patch...
    Pre-processing patch...
    ✔ Saved patch to '/$HOME/src/neovim/vim-8.0.0615.patch'.

    Fetching 'origin/master'.
    ✔ From https://github.com/neovim/neovim
     * branch                master     -> FETCH_HEAD

    Creating new branch 'vim-8.0.0615' based on 'origin/master'.
    ✔ Switched to a new branch 'vim-8.0.0615'
    Branch 'vim-8.0.0615' set up to track remote branch 'master' from 'origin'.

    Creating empty commit with correct commit message.
    ./scripts/vim-patch.sh: line 40: printf: `w': invalid format character
    ✔ [vim-8.0.0615 db7fbb016] vim-patch:8.0.0615: using ./scripts/vim-patch.sh: line 44: printf: `w': invalid format character
    ✘ [vim-8.0.0615 db7fbb016] vim-patch:8.0.0615: using

[ci-skip]
This commit is contained in:
James McCoy
2018-06-19 09:27:32 -04:00
parent 63b5f05d47
commit c8af12d0fa

View File

@@ -37,11 +37,11 @@ usage() {
}
msg_ok() {
printf "\e[32m✔\e[0m $@\n"
printf '\e[32m✔\e[0m %s\n' "$@"
}
msg_err() {
printf "\e[31m✘\e[0m $@\n"
printf '\e[31m✘\e[0m %s\n' "$@"
}
# Checks if a program is in the user's PATH, and is executable.
@@ -218,7 +218,7 @@ stage_patch() {
local git_remote
git_remote="$(find_git_remote)"
local checked_out_branch
checked_out_branch="$(git rev-parse --abbrev-ref HEAD)"
checked_out_branch="$(git rev-parse --abbrev-ref HEAD)"
if [[ "${checked_out_branch}" == ${BRANCH_PREFIX}* ]]; then
msg_ok "Current branch '${checked_out_branch}' seems to be a vim-patch"
@@ -248,21 +248,22 @@ stage_patch() {
printf "\n"
msg_err "'patch' command not found\n"
else
printf "\nApplying patch...\n"
printf "\nApplying patch...\n"
patch -p1 < "${patch_file}" || true
find -name '*.orig' -type f -delete
fi
printf "\nInstructions:\n Proceed to port the patch.\n"
fi
printf "\nInstructions:\n Proceed to port the patch.\n"
else
printf "\nInstructions:\n Proceed to port the patch.\n Try the 'patch' command (or use '${BASENAME} -P ...' next time):\n patch -p1 < ${patch_file}\n"
fi
printf '\nInstructions:\n Proceed to port the patch.\n Try the "patch" command (or use "%s -P ..." next time):\n patch -p1 < %s\n' "${BASENAME}" "${patch_file}"
fi
printf '
Stage your changes ("git add ..."), then use "git commit --amend" to commit.
To port more patches (if any) related to %s,
run "%s" again.
* Do this only for _related_ patches (otherwise it increases the
* Do this only for _related_ patches (otherwise it increases the
size of the pull request, making it harder to review)
When you are done, try "%s -s" to create the pull request.
@@ -398,24 +399,24 @@ show_vimpatches() {
}
# Prints a human-formatted list of Vim commits, with instructional messages.
show_vimpatches() {
show_vimpatches() {
get_vim_sources
printf "\nVim patches missing from Neovim:\n"
printf "\nVim patches missing from Neovim:\n"
list_missing_vimpatches | while read vim_commit; do
if (cd "${VIM_SOURCE_DIR}" && git --no-pager show --color=never --name-only "v${vim_commit}" 2>/dev/null) | grep -q ^runtime; then
printf "${vim_commit} (+runtime)\n"
else
printf "${vim_commit}\n"
fi
done
echo
echo "Instructions:"
echo
echo " To port one of the above patches to Neovim, execute"
echo " this script with the patch revision as argument and"
echo " follow the instructions."
printf ' • %s (+runtime)\n' "${vim_commit}"
else
printf ' • %s\n' "${vim_commit}"
fi
done
printf "Instructions:
To port one of the above patches to Neovim, execute
this script with the patch revision as argument and
follow the instructions.
Examples: '%s -p 7.4.487'
'%s -p 1e8ebf870720e7b671f98f22d653009826304c4f'
@@ -436,7 +437,7 @@ review_commit() {
echo
if [[ -n "${vim_version}" ]]; then
msg_ok "Detected Vim patch '${vim_version}'."
msg_ok "Detected Vim patch '${vim_version}'."
else
msg_err "Could not detect the Vim patch number."
echo " This script assumes that the PR contains only commits"