diff options
author | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2019-04-14 01:36:13 (EDT) |
---|---|---|
committer | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2019-04-14 01:36:13 (EDT) |
commit | 049f1d1434c5e3dc5f1c6a0d57711b33911c3b12 (patch) | |
tree | 3a7cd9ab47da1a93efc2b4a37d6064ef3cd8608f /src/main.sh | |
parent | 38c211c927c942d30946dfc7caaa5bb6535ea66a (diff) |
Protect against cmd operands beginning with "-"
Diffstat (limited to 'src/main.sh')
-rw-r--r-- | src/main.sh | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/main.sh b/src/main.sh index 7af0810..5998e9c 100644 --- a/src/main.sh +++ b/src/main.sh @@ -43,7 +43,7 @@ exit_status= _lock() { - mkdir -p "${base_dir}/.db" + mkdir -p -- "${base_dir}/.db" lock="${base_dir}/.db/lock" if ! (set -C; printf '%d\n' "${$}" >"${lock}") 2>/dev/null; then error 2 "$(get_msg 'lock_fail')" @@ -52,7 +52,7 @@ _lock() _unlock() { - rm -f "${lock}" + rm -f -- "${lock}" } _handle_sig() @@ -63,9 +63,9 @@ _handle_sig() _unlock if [ "x${exit_status:+set}" = 'xset' ]; then - exit ${exit_status} + exit -- ${exit_status} else - exit $((128 + ${sig})) + exit -- $((128 + ${sig})) fi } @@ -116,14 +116,14 @@ _get_conf() conf_gzip=true conf_key='' - eval "$(cat "${base_dir}/conf" 2>/dev/null || :)" + eval "$(cat -- "${base_dir}/conf" 2>/dev/null || :)" old_dir="$(pwd)" - cd "${base_dir}" + cd -- "${base_dir}" if [ -d "${conf_incoming_dir}" ]; then - conf_incoming_dir="$(cd "${conf_incoming_dir}" && pwd)" + conf_incoming_dir="$(cd -- "${conf_incoming_dir}" && pwd)" fi - cd "${old_dir}" + cd -- "${old_dir}" case "${conf_pool_gc_delay}" in *[!0-9]* | '') error 1 "$(get_msg 'conf_invalid')" 'conf_pool_gc_delay' @@ -158,9 +158,9 @@ main() local cmd= local status= - if [ -f "$(dirname "${0}")/.builddirstamp" ]; then + if [ -f "$(dirname -- "${0}")/.builddirstamp" ]; then in_place=true - builddir="$(dirname "${0}")" + builddir="$(dirname -- "${0}")" else in_place=false builddir='' |