Separate filenames from options whenever necessary. Style.

Whenever we're using dynamically-passed filenames, use '--' to separate
them from options. Additionally, always use braces around variable
names.
This commit is contained in:
Michał Górny 2010-07-13 17:34:42 +02:00
parent 72435c1a73
commit 304ef4db49

View File

@ -23,7 +23,7 @@ sayv() {
# Execute the command and die with simple error message if it fails.
req() {
"$@" || die "'$@' failed."
"${@}" || die "'${@}' failed."
}
# -- POSIX compat --
@ -161,9 +161,9 @@ check_for_changes() {
local output
if [ ${SC_VCS%-svn} = git ]; then
output=$(git diff-index --name-only --relative HEAD "$@")
output=$(git diff-index --name-only --relative HEAD -- "${@}")
elif [ ${SC_VCS} = svn ]; then
output=$(svn status "$@")
output=$(svn status -- "${@}")
fi
[ -z "${output}" ] && return 1
@ -174,26 +174,26 @@ check_for_changes() {
# Discard any changes to a particular set of files.
vcs_reset() {
if [ ${SC_VCS%-svn} = git ]; then
req git reset -q HEAD "${@}"
git checkout -f "${@}" 2>/dev/null || req rm -f "${@}"
req git reset -q HEAD -- "${@}"
git checkout -f -- "${@}" 2>/dev/null || req rm -f -- "${@}"
elif [ ${SC_VCS} = svn ]; then
req rm -f "${@}"
svn up "${@}" >/dev/null 2>&1
req rm -f -- "${@}"
svn up -- "${@}" >/dev/null 2>&1
fi
}
# Request VCS to provide a verbose status report.
vcs_status() {
if [ ${SC_VCS%-svn} = git ]; then
git status -s ${1-.} "${@}"
git status -s -- ${1-.} "${@}"
elif [ ${SC_VCS} = svn ]; then
svn status "${@}"
svn status -- "${@}"
fi
}
# Add particular files to the repository.
vcs_add() {
${SC_VCS%-svn} add "$@"
${SC_VCS%-svn} add -- "${@}"
}
# Commit the specified objects using the commit message provided
@ -204,9 +204,9 @@ vcs_commit() {
shift
if [ ${SC_VCS%-svn} = git ]; then
exec git commit -m "${msg}" ${1+-o} "${@}"
exec git commit -m "${msg}" ${1+-o} -- "${@}"
elif [ ${SC_VCS} = svn ]; then
exec svn commit -m "${msg}" "${@}"
exec svn commit -m "${msg}" -- "${@}"
fi
}
@ -215,7 +215,7 @@ vcs_update() {
# Unlike svn, git doesn't push the changes to origin immediately,
# and that's why we don't force update to it right here.
if [ ${SC_VCS} = svn ]; then
svn up || say 'Warning: svn up failed, trying to proceed anyway.'
svn up -- "${@}" || say 'Warning: svn up failed, trying to proceed anyway.'
fi
}
@ -411,7 +411,7 @@ main() {
local old_repoman
repoman --version -a >/dev/null 2>&1
if [ $? -eq 2 ]; then
if [ ${?} -eq 2 ]; then
old_repoman=
#say "${GREEN}Please consider updating portage to newer version.${RESET}"