Permalink
Browse files

do not show warning on shift when nothing to shift

  • Loading branch information...
1 parent 2913d9a commit ddb249bdd7f1aab897d1875e72d4a76d7f3f7b45 @mpapis mpapis committed Sep 17, 2011
Showing with 213 additions and 213 deletions.
  1. +14 −14 core/api/shell/array/functions
  2. +4 −4 core/api/shell/command/functions
  3. +5 −5 core/api/shell/config/functions
  4. +3 −3 core/api/shell/database/extensions
  5. +5 −5 core/api/shell/date/functions
  6. +2 −2 core/api/shell/extensions/functions
  7. +12 −12 core/api/shell/files/functions
  8. +2 −2 core/api/shell/hash/functions
  9. +1 −1 core/api/shell/interactive/functions
  10. +2 −2 core/api/shell/os/functions
  11. +3 −3 core/api/shell/package/extensions
  12. +13 −13 core/api/shell/package/functions
  13. +8 −8 core/api/shell/paths/functions
  14. +3 −3 core/api/shell/service/extensions
  15. +1 −1 core/api/shell/steps/functions
  16. +2 −2 core/api/shell/string/functions
  17. +4 −4 core/api/shell/templates/functions
  18. +2 −2 core/api/shell/traps/functions
  19. +7 −7 core/api/shell/user/functions
  20. +2 −2 core/cli/shell/dev/functions
  21. +1 −1 core/cli/shell/ext/functions
  22. +1 −1 core/cli/shell/functions
  23. +2 −2 core/cli/shell/sets/functions
  24. +1 −1 core/install/shell/functions
  25. +6 −6 core/internal/shell/array/functions
  26. +1 −1 core/internal/shell/config/extensions
  27. +3 −3 core/internal/shell/database/extensions
  28. +2 −2 core/internal/shell/extensions/cache/functions
  29. +4 −4 core/internal/shell/extensions/common/functions
  30. +3 −3 core/internal/shell/extensions/completion/functions
  31. +4 −4 core/internal/shell/extensions/detection/functions
  32. +7 −7 core/internal/shell/extensions/manipulation/functions
  33. +3 −3 core/internal/shell/files/functions
  34. +1 −1 core/internal/shell/os/functions
  35. +3 −3 core/internal/shell/package/extensions
  36. +4 −4 core/internal/shell/package/functions
  37. +1 −1 core/internal/shell/paths/functions
  38. +1 −1 core/internal/shell/processes/functions
  39. +3 −3 core/internal/shell/service/extensions
  40. +3 −3 core/internal/shell/service/functions
  41. +1 −1 core/internal/shell/services/functions
  42. +1 −1 core/internal/shell/steps/functions
  43. +5 −5 core/internal/shell/templates/functions
  44. +2 −2 core/internal/shell/variables/functions
  45. +5 −5 core/internal/shell/vcs/detection/functions
  46. +2 −2 core/internal/shell/vcs/errors/functions
  47. +11 −11 core/internal/shell/vcs/functions
  48. +2 −2 core/internal/shell/vcs/handlers/archive/functions
  49. +2 −2 core/internal/shell/vcs/handlers/git/functions
  50. +2 −2 core/internal/shell/vcs/handlers/github/functions
  51. +2 −2 core/internal/shell/vcs/handlers/hg/functions
  52. +2 −2 core/internal/shell/vcs/handlers/path/functions
  53. +2 −2 core/internal/shell/vcs/handlers/svn/functions
  54. +11 −11 core/sm/shell/log/functions
  55. +5 −5 core/sm/shell/modules/functions
  56. +9 −9 core/sm/shell/versionedfs/functions
View
28 core/api/shell/array/functions
@@ -31,12 +31,12 @@ array()
trace_filter array || set -o xtrace
local _command _subcommand _name _variable
_command="$1"
- shift || __sm.log.fail "Array command must be given as the first parameter."
+ (( $# )) && shift || __sm.log.fail "Array command must be given as the first parameter."
case "${_command}" in
(is)
_subcommand="$1" _name="$2"
- shift 2 || __sm.log.fail "subcommand and array name missing;"\
+ (( $# >= 2 )) && shift 2 || __sm.log.fail "subcommand and array name missing;"\
" array is <empty,nonempty,even> {name}"
case "${_subcommand}" in
(empty)
@@ -55,65 +55,65 @@ array()
;;
(length)
_name="$1"
- shift || __sm.log.fail "Array name missing: array length {name}"
+ (( $# )) && shift || __sm.log.fail "Array name missing: array length {name}"
__sm.array.length "${_name}"
;;
(last)
_name="$1"
- shift || __sm.log.fail "Array name missing: array last {name}"
+ (( $# )) && shift || __sm.log.fail "Array name missing: array last {name}"
__sm.array.last "${_name}"
;;
(first)
_name="$1"
- shift || __sm.log.fail "Array name missing: array first {name}"
+ (( $# )) && shift || __sm.log.fail "Array name missing: array first {name}"
__sm.array.first "${_name}"
;;
(push)
_name="$1" _element="$2"
- shift 2 || __sm.log.fail "Array name or element missing:"\
+ (( $# >= 2 )) && shift 2 || __sm.log.fail "Array name or element missing:"\
" array push {name} {element}"
__sm.array.push "${_name}" "${_element}"
;;
(pop)
_name="$1" _variable="${2:-}"
- shift || __sm.log.fail "Array name missing: array pop {name} [{variable}]"
+ (( $# )) && shift || __sm.log.fail "Array name missing: array pop {name} [{variable}]"
__sm.array.pop "${_name}" "${_variable}"
;;
(append)
_name="$1" _element="$2"
- shift 2 || __sm.log.fail "Array name or element missing:"\
+ (( $# >= 2 )) && shift 2 || __sm.log.fail "Array name or element missing:"\
" array append {name} {element}"
__sm.array.append "${_name}" "${_element}"
;;
(shift)
_name="$1" _variable="${2:-}"
- shift || __sm.log.fail "Array name missing: array shift {name} [{variable}]"
+ (( $# )) && shift || __sm.log.fail "Array name missing: array shift {name} [{variable}]"
__sm.array.shift "${_name}" "${_variable}"
;;
(unshift)
_name="$1"
- shift || __sm.log.fail "Array name missing: array unshift {name} [{variable}]"
+ (( $# )) && shift || __sm.log.fail "Array name missing: array unshift {name} [{variable}]"
__sm.array.unshift "${_name}" "${_variable}"
;;
(join)
_name="$1" _separator="${2:-' '}"
- shift || __sm.log.fail "Array name missing: array join {name} [separator]"
+ (( $# )) && shift || __sm.log.fail "Array name missing: array join {name} [separator]"
__sm.array.join "${_name}" "${_separator}"
;;
(largest)
_name="$1"
- shift || __sm.log.fail "Array name missing: array largest {name}"
+ (( $# )) && shift || __sm.log.fail "Array name missing: array largest {name}"
__sm.array.largest "${_name}"
;;
(sort)
_subcommand="$1" _name="$2"
- shift 2 || __sm.log.fail "sort direction and array name missing;"\
+ (( $# >= 2 )) && shift 2 || __sm.log.fail "sort direction and array name missing;"\
" array sort <desc,asc> {name}."
__sm.array.sort "${_name}" "${_subcommand}"
;;
(unique)
_name="$1"
- shift || __sm.log.fail "Array name missing: array unique {name}."
+ (( $# )) && shift || __sm.log.fail "Array name missing: array unique {name}."
__sm.array.unique "${_name}"
;;
(start)
View
8 core/api/shell/command/functions
@@ -16,7 +16,7 @@ command()
;;
(is)
_subcommand="$1"
- shift || __sm.log.fail "A command must follow keyword 'is'; <function>"
+ (( $# )) && shift || __sm.log.fail "A command must follow keyword 'is'; <function>"
case "${_subcommand}" in
(function)
if __sm.command.is.function "$1" >/dev/null 2>&1
@@ -31,14 +31,14 @@ command()
;;
(full)
_subcommand="$1"
- shift || __sm.log.fail "A 'command full' must follow keyword 'name'."
+ (( $# )) && shift || __sm.log.fail "A 'command full' must follow keyword 'name'."
case "${_subcommand}" in
(name)
if __sm.command.full.name "$1" >/dev/null 2>&1
then return 0 ; else return 1 ; fi
;;
(*)
- shift || __sm.log.fail "A 'command full' must follow keyword 'name'."
+ (( $# )) && shift || __sm.log.fail "A 'command full' must follow keyword 'name'."
;;
esac
;;
@@ -47,7 +47,7 @@ command()
(as)
shift
_user="$1"
- shift || __sm.log.fail "A user name or id must be specified after keyword 'as'"
+ (( $# )) && shift || __sm.log.fail "A user name or id must be specified after keyword 'as'"
# TODO: Check to ensure user name/id exists on the system
if __sm.command.run.as "${_user}" "${_flags[*]}" "$@"
then return 0 ; else return 1 ; fi
View
10 core/api/shell/config/functions
@@ -15,23 +15,23 @@ config()
;;
(key)
_key="$1"
- shift || __sm.log.fail "a key must be given after keywords 'key'"
+ (( $# )) && shift || __sm.log.fail "a key must be given after keywords 'key'"
;;
(value)
_value="$1"
- shift || __sm.log.fail "a value must be given after keywords 'value'"
+ (( $# )) && shift || __sm.log.fail "a value must be given after keywords 'value'"
;;
(into|as)
_variable="$1"
- shift || __sm.log.fail "a variable name must be given after keywords 'into|as'"
+ (( $# )) && shift || __sm.log.fail "a variable name must be given after keywords 'into|as'"
;;
(prefix) # TODO: Nix prefix?
_prefix="$1"
- shift || __sm.log.fail "a prefix name must be given after keyword 'prefix'"
+ (( $# )) && shift || __sm.log.fail "a prefix name must be given after keyword 'prefix'"
;;
(file)
_file="$1"
- shift || __sm.log.fail "a file name must be given after keyword 'file'"
+ (( $# )) && shift || __sm.log.fail "a file name must be given after keyword 'file'"
;;
(from)
_extension="$1" || __sm.log.fail "An extension name must follow keyword 'for'"
View
6 core/api/shell/database/extensions
@@ -7,9 +7,9 @@ database_extension_setup()
extension="${1}"
module="${2}"
path="${3}"
- shift || __sm.log.fail "Extension must be given as the first parameter."
- shift || __sm.log.fail "Module must be given as the second parameter."
- shift || __sm.log.fail "Path must be given as the third parameter."
+ (( $# )) && shift || __sm.log.fail "Extension must be given as the first parameter."
+ (( $# )) && shift || __sm.log.fail "Module must be given as the second parameter."
+ (( $# )) && shift || __sm.log.fail "Path must be given as the third parameter."
paths enter "${path}"
View
10 core/api/shell/date/functions
@@ -15,23 +15,23 @@ date()
case "${_token}" in
(step)
_step="${1:-}"
- shift || __sm.log.fail "step must follow keyword 'step'"
+ (( $# )) && shift || __sm.log.fail "step must follow keyword 'step'"
;;
(format_in)
_format_in="${1}"
- shift || __sm.log.fail "input format must follow keyword 'format_in'"
+ (( $# )) && shift || __sm.log.fail "input format must follow keyword 'format_in'"
;;
(format|format_out)
_format_out="${1}"
- shift || __sm.log.fail "output format must follow keyword 'format[_out]'"
+ (( $# )) && shift || __sm.log.fail "output format must follow keyword 'format[_out]'"
;;
(start)
_start="${1}"
- shift || __sm.log.fail "start must follow keyword 'start'"
+ (( $# )) && shift || __sm.log.fail "start must follow keyword 'start'"
;;
(end)
_end="${1}"
- shift || __sm.log.fail "end must follow keyword 'end'"
+ (( $# )) && shift || __sm.log.fail "end must follow keyword 'end'"
;;
(*)
if [[ -z "${_start}" ]]
View
4 core/api/shell/extensions/functions
@@ -30,11 +30,11 @@ extension()
case "$1" in
(name|for|as)
_name=$2
- shift 2 || __sm.log.fail "Extension name was not given after <$1> param."
+ (( $# >= 2 )) && shift 2 || __sm.log.fail "Extension name was not given after <$1> param."
;;
(uri|from)
_uri=$2
- shift 2 || __sm.log.fail "Extension uri was not given after <$1> param."
+ (( $# >= 2 )) && shift 2 || __sm.log.fail "Extension uri was not given after <$1> param."
;;
(*)
_params+=( "$1" )
View
24 core/api/shell/files/functions
@@ -45,11 +45,11 @@ files()
;;
(chmod)
_mode="${1}"
- shift || __sm.log.fail "Mode must follow keywords 'chmod'"
+ (( $# )) && shift || __sm.log.fail "Mode must follow keywords 'chmod'"
;;
(chown)
_owner="${1}"
- shift || __sm.log.fail "Owner must be provided after keyword 'owner'"
+ (( $# )) && shift || __sm.log.fail "Owner must be provided after keyword 'owner'"
;;
esac
@@ -62,19 +62,19 @@ files()
;;
(to)
_target="${1}"
- shift || __sm.log.fail "Target path must be provided after keyword '${_token}'"
+ (( $# )) && shift || __sm.log.fail "Target path must be provided after keyword '${_token}'"
;;
(from)
_source="${1}"
- shift || __sm.log.fail "Source path must be provided after keyword 'from'"
+ (( $# )) && shift || __sm.log.fail "Source path must be provided after keyword 'from'"
;;
(mode|permissions)
_mode="${1}"
- shift || __sm.log.fail "Mode must follow keywords 'mode|permissions'"
+ (( $# )) && shift || __sm.log.fail "Mode must follow keywords 'mode|permissions'"
;;
(owner)
_owner="${1}"
- shift || __sm.log.fail "Owner must be provided after keyword 'owner'"
+ (( $# )) && shift || __sm.log.fail "Owner must be provided after keyword 'owner'"
;;
(recursive|recursively)
_flags+=(-R)
@@ -88,27 +88,27 @@ files()
;;
(string|content)
_string="$1"
- shift || __sm.log.fail "A string must be followed by keyword 'string'"
+ (( $# )) && shift || __sm.log.fail "A string must be followed by keyword 'string'"
;;
(regex)
_regex="$1"
- shift || __sm.log.fail "A regex must be followed by keyword 'regex'"
+ (( $# )) && shift || __sm.log.fail "A regex must be followed by keyword 'regex'"
;;
(in)
_files+=("$1")
- shift || __sm.log.fail "A file name must follow keyword 'in'"
+ (( $# )) && shift || __sm.log.fail "A file name must follow keyword 'in'"
;;
(key)
_key="$1"
- shift || __sm.log.fail "A key name must follow keyword 'key'"
+ (( $# )) && shift || __sm.log.fail "A key name must follow keyword 'key'"
;;
(value)
_value="$1"
- shift || __sm.log.fail "A value must follow keyword 'value'"
+ (( $# )) && shift || __sm.log.fail "A value must follow keyword 'value'"
;;
(with)
_string="$1"
- shift || __sm.log.fail "A content string must follow keyword 'with'"
+ (( $# )) && shift || __sm.log.fail "A content string must follow keyword 'with'"
;;
(*)
_files+=("${_token}")
View
4 core/api/shell/hash/functions
@@ -19,11 +19,11 @@ hash()
;;
(key)
_key="$1"
- shift || __sm.log.fail "Key name must follow keyword 'key'"
+ (( $# )) && shift || __sm.log.fail "Key name must follow keyword 'key'"
;;
(variable)
_variable="$1"
- shift || __sm.log.fail "Variable name must follow keyword 'variable'"
+ (( $# )) && shift || __sm.log.fail "Variable name must follow keyword 'variable'"
;;
(*)
if [[ -z "${_command}" ]]
View
2 core/api/shell/interactive/functions
@@ -10,7 +10,7 @@ shell()
(is)
_command=is
_subcommand="${1}"
- shift || __sm.log.fail "A command must follow keyword 'is'"
+ (( $# )) && shift || __sm.log.fail "A command must follow keyword 'is'"
case "${_subcommand}" in
(interactive)
[[ -t 0 ]]
View
4 core/api/shell/os/functions
@@ -22,13 +22,13 @@ os()
(is)
_command="$token"
_os="${1}"
- shift || __sm.log.fail "lowercase operating system name must follow keyword 'os';"\
+ (( $# )) && shift || __sm.log.fail "lowercase operating system name must follow keyword 'os';"\
"os is <linux|darwin|bsd|solaris|aix>"
;;
(cpu)
_command=cpu
_subcommand="$1"
- shift || __sm.log.fail "A command must follow keyword 'cpu'; one of {count}"
+ (( $# )) && shift || __sm.log.fail "A command must follow keyword 'cpu'; one of {count}"
case "${_subcommand}" in
(count)
true # all good.
View
6 core/api/shell/package/extensions
@@ -7,9 +7,9 @@ package_extension_setup()
module="${2:-}"
path="${3:-}"
true ${language:=shell}
- shift || __sm.log.fail "No extension name given."
- shift || __sm.log.fail "No module name given."
- shift || __sm.log.fail "No path given."
+ (( $# )) && shift || __sm.log.fail "No extension name given."
+ (( $# )) && shift || __sm.log.fail "No module name given."
+ (( $# )) && shift || __sm.log.fail "No path given."
for action in install uninstall update activate deactivate
do
View
26 core/api/shell/package/functions
@@ -65,15 +65,15 @@ package()
;;
(log)
_log="$1"
- shift || __sm.log.fail "Log file path/name must be given following keyword 'log'"
+ (( $# )) && shift || __sm.log.fail "Log file path/name must be given following keyword 'log'"
;;
(lines)
_lines="$1"
- shift || __sm.log.fail "Number of lines to show must be given following keyword 'lines'"
+ (( $# )) && shift || __sm.log.fail "Number of lines to show must be given following keyword 'lines'"
;;
(message)
_message="$1"
- shift || __sm.log.fail "Message must be given following keyword 'message'"
+ (( $# )) && shift || __sm.log.fail "Message must be given following keyword 'message'"
;;
(configure)
_command=configure
@@ -114,43 +114,43 @@ package()
;;
(key)
_key="$1"
- shift || __sm.log.fail "Key name must follow keyword 'key'"
+ (( $# )) && shift || __sm.log.fail "Key name must follow keyword 'key'"
;;
(name)
package_name="$1"
- shift || __sm.log.fail "a package name must follow keyword 'name'"
+ (( $# )) && shift || __sm.log.fail "a package name must follow keyword 'name'"
;;
(version)
package_version="$1"
- shift || __sm.log.fail "a package version must follow keyword 'version'"
+ (( $# )) && shift || __sm.log.fail "a package version must follow keyword 'version'"
;;
(base_url)
package_base_url="$1"
- shift || __sm.log.fail "a package base_url must follow keyword 'base_url'"
+ (( $# )) && shift || __sm.log.fail "a package base_url must follow keyword 'base_url'"
;;
(file)
package_file="$1"
- shift || __sm.log.fail "a package file name must follow keyword 'file'"
+ (( $# )) && shift || __sm.log.fail "a package file name must follow keyword 'file'"
;;
(user)
package_user="$1"
- shift || __sm.log.fail "a package user name must follow keyword 'user'"
+ (( $# )) && shift || __sm.log.fail "a package user name must follow keyword 'user'"
;;
(archive_format)
archive_format="$1"
- shift || __sm.log.fail "a package archive_format must follow keyword 'archive_format'"
+ (( $# )) && shift || __sm.log.fail "a package archive_format must follow keyword 'archive_format'"
;;
(md5)
package_md5="$1"
- shift || __sm.log.fail "a package md5 sum must follow keyword 'md5'"
+ (( $# )) && shift || __sm.log.fail "a package md5 sum must follow keyword 'md5'"
;;
(sha256)
package_sha256="$1"
- shift || __sm.log.fail "a package sha256 key must follow keyword 'sha256'"
+ (( $# )) && shift || __sm.log.fail "a package sha256 key must follow keyword 'sha256'"
;;
(sha512)
package_sha512="$1"
- shift || __sm.log.fail "a package sha512 key must follow keyword 'sha512'"
+ (( $# )) && shift || __sm.log.fail "a package sha512 key must follow keyword 'sha512'"
;;
(*)
_params+=("${_token}")
View
16 core/api/shell/paths/functions
@@ -68,11 +68,11 @@ paths()
case "${_command}" in
(chmod)
_mode="${1}"
- shift || __sm.log.fail "Mode must follow keywords 'chmod'"
+ (( $# )) && shift || __sm.log.fail "Mode must follow keywords 'chmod'"
;;
(chown)
_owner="${1}"
- shift || __sm.log.fail "Owner must be provided after keyword 'owner'"
+ (( $# )) && shift || __sm.log.fail "Owner must be provided after keyword 'owner'"
;;
esac
@@ -82,31 +82,31 @@ paths()
case "${_token}" in
(to)
_target="${1}"
- shift || __sm.log.fail "Target path must be given after keyword 'to'"
+ (( $# )) && shift || __sm.log.fail "Target path must be given after keyword 'to'"
;;
(from)
_source="${1}"
- shift || __sm.log.fail "Source path must be given after keyword 'from'"
+ (( $# )) && shift || __sm.log.fail "Source path must be given after keyword 'from'"
;;
(mode|permissions)
_mode="${1}"
- shift || __sm.log.fail "Mode must follow keyword '${_token}'"
+ (( $# )) && shift || __sm.log.fail "Mode must follow keyword '${_token}'"
;;
(owner)
_owner="${1}"
- shift || __sm.log.fail "Owner must be given after keyword 'owner'"
+ (( $# )) && shift || __sm.log.fail "Owner must be given after keyword 'owner'"
;;
(recursive|recursively)
_flags+=(-R)
;;
(matching|regex|glob)
_regex="$1"
- shift ||
+ (( $# )) && shift ||
__sm.log.fail "Shell glob pattern string must b given after keyword '${_token}'"
;;
(in)
_paths+=("$1")
- shift || __sm.log.fail "A path is expected following keyword 'in'"
+ (( $# )) && shift || __sm.log.fail "A path is expected following keyword 'in'"
;;
(*)
_paths+=("${_token}")
View
6 core/api/shell/service/extensions
@@ -7,9 +7,9 @@ service_extension_setup()
module="${2:-}"
path="${3:-}"
true ${language:=shell}
- shift || __sm.log.fail "Extension name not given as first parameter."
- shift || __sm.log.fail "Module name not given as second parameter."
- shift || __sm.log.fail "Path not given as third parameter."
+ (( $# )) && shift || __sm.log.fail "Extension name not given as first parameter."
+ (( $# )) && shift || __sm.log.fail "Module name not given as second parameter."
+ (( $# )) && shift || __sm.log.fail "Path not given as third parameter."
for action in start stop restart status list
do
View
2 core/api/shell/steps/functions
@@ -7,7 +7,7 @@ step()
local name
name="$1"
- shift || __sm.log.fail "Cannot take step as no step name given;"\
+ (( $# )) && shift || __sm.log.fail "Cannot take step as no step name given;"\
"step [name] <- missing name."
start_step "$name"
View
4 core/api/shell/string/functions
@@ -14,15 +14,15 @@ string()
case "${_token}" in
(from)
_search="$1"
- shift || __sm.log.fail "From source string must follow keyword 'from'"
+ (( $# )) && shift || __sm.log.fail "From source string must follow keyword 'from'"
;;
(to)
_string="$1"
;;
(contains)
_command=contains
_search="$1"
- shift || __sm.log.fail "Search (glob) string must follow keyword 'contains'"
+ (( $# )) && shift || __sm.log.fail "Search (glob) string must follow keyword 'contains'"
;;
(*)
if [[ -z "${_string}" ]]
View
8 core/api/shell/templates/functions
@@ -41,23 +41,23 @@ templates()
fi
_name="$1"
- shift || __sm.log.fail "Template name was not given"
+ (( $# )) && shift || __sm.log.fail "Template name was not given"
while (( $# > 0 ))
do
_token="${1}" && shift
case "${_token}" in
(to)
_target="$1"
- shift || __sm.log.fail "target path must follow keyword 'to'"
+ (( $# )) && shift || __sm.log.fail "target path must follow keyword 'to'"
;;
(mode)
_mode="$1"
- shift || __sm.log.fail "mode must follow keyword 'mode'"
+ (( $# )) && shift || __sm.log.fail "mode must follow keyword 'mode'"
;;
(owner)
_owner="$1"
- shift || __sm.log.fail "owner must follow keyword 'owner'"
+ (( $# )) && shift || __sm.log.fail "owner must follow keyword 'owner'"
;;
(from)
__sm.log.fail "'from' keyword is no longer supported"
View
4 core/api/shell/traps/functions
@@ -15,11 +15,11 @@ traps()
case "${_token}" in
(on)
_signal="$1"
- shift || __sm.log.fail "A signal must follow keyword 'on'"
+ (( $# )) && shift || __sm.log.fail "A signal must follow keyword 'on'"
case "${_signal}" in
(exit|EXIT)
_code="$*"
- shift || __sm.log.fail "The code to be run on EXIT must be given after keyword 'EXIT'."
+ (( $# )) && shift || __sm.log.fail "The code to be run on EXIT must be given after keyword 'EXIT'."
__traps_code="$(trap)"
__traps_code="$( echo "${__traps_code}" | awk '/ EXIT$/' |
sed -e "s#' EXIT##" -e "s#.*'##")"
View
14 core/api/shell/user/functions
@@ -29,17 +29,17 @@ user()
case "${_command}" in
(set.home)
_value="$1"
- shift || __sm.log.fail "A home path must follow keyword 'home';"\
+ (( $# )) && shift || __sm.log.fail "A home path must follow keyword 'home';"\
"user set home /home/{username} for {username}"
;;
(set.shell)
_value="$1"
- shift || __sm.log.fail "A shell must follow keyword 'shell'"\
+ (( $# )) && shift || __sm.log.fail "A shell must follow keyword 'shell'"\
"user set shell /bin/zsh for {username}"
;;
(exists)
_user="$1"
- shift || __sm.log.fail "A user name must follow keyword 'exists'"\
+ (( $# )) && shift || __sm.log.fail "A user name must follow keyword 'exists'"\
"user exists {username}"
;;
esac
@@ -53,19 +53,19 @@ user()
;;
(name|user|for)
_user="$1"
- shift || __sm.log.fail "User name must follow keyword 'user'"
+ (( $# )) && shift || __sm.log.fail "User name must follow keyword 'user'"
;;
(group)
_group="${1:-}"
- shift || __sm.log.fail "Group name must follow keyword 'group'"
+ (( $# )) && shift || __sm.log.fail "Group name must follow keyword 'group'"
;;
(from)
_source="${1:-}"
- shift || __sm.log.fail "from source name must follow keyword 'from'"
+ (( $# )) && shift || __sm.log.fail "from source name must follow keyword 'from'"
;;
(shell)
_shell="${1:-}"
- shift || __sm.log.fail "A user shell (/bin/{zsh,bash}) must follow keyword 'shell'"
+ (( $# )) && shift || __sm.log.fail "A user shell (/bin/{zsh,bash}) must follow keyword 'shell'"
;;
(force)
_flags+=(-f)
View
4 core/cli/shell/dev/functions
@@ -85,7 +85,7 @@ extension_package()
{
local _name _path _version file _archiver
_name="${1:-}"
- shift || __sm.log.fail "Cannot package an extension; no extension name was given."
+ (( $# )) && shift || __sm.log.fail "Cannot package an extension; no extension name was given."
_path="${extensions_development_path:-"$extensions_src_path"}"
@@ -126,7 +126,7 @@ extension_publish()
{
local _name _path _version _file
_name="${1:-}"
- shift || __sm.log.fail "Cannot publish an extension; no extension name was given."
+ (( $# )) && shift || __sm.log.fail "Cannot publish an extension; no extension name was given."
NIY "Extension publishing locally and to extensions.beginrescueend.com has not yet been implemented."
View
2 core/cli/shell/ext/functions
@@ -68,7 +68,7 @@ ext_install()
local _name _names _uri
_names="$1"
_uri="$2"
- shift || __sm.log.fail "No extension name was given."
+ (( $# )) && shift || __sm.log.fail "No extension name was given."
_names=(${_names//,/ })
View
2 core/cli/shell/functions
@@ -47,7 +47,7 @@ actions()
{
local _action _token
_action="$1"
- shift || __sm.log.fail "Actions command not given."
+ (( $# )) && shift || __sm.log.fail "Actions command not given."
while (( $# ))
do
View
4 core/cli/shell/sets/functions
@@ -74,7 +74,7 @@ sets_install()
{
local _name _names _extension_namespace
_names="${1:-}"
- shift || __sm.log.fail "No set name was given."
+ (( $# )) && shift || __sm.log.fail "No set name was given."
_names=( ${=_names//,/ } )
_extension_namespace="${sets_user_path#${sm_path}\/}"
@@ -90,7 +90,7 @@ set_install()
{
local _name _uri _identifier _version
_name="${1:-}"
- shift || __sm.log.fail "No set name was given."
+ (( $# )) && shift || __sm.log.fail "No set name was given."
_uri="${1:-}"
(( $# )) && shift || _uri=$( awk -F= "/^${_name}=/ {print \$2 }" < "${sm_path}/core/cli/config/known_sets" | tail -n 1 )
View
2 core/install/shell/functions
@@ -43,7 +43,7 @@ cleanse_targets()
{
local _path _entity
_path="$1"
- shift || __sm.log.fail "Usage:\n\n cleanse_targets {target} {paths/files under target}"
+ (( $# )) && shift || __sm.log.fail "Usage:\n\n cleanse_targets {target} {paths/files under target}"
for _entity in "$@"
do
rm -rf "${_path}/${_entity}"
View
12 core/internal/shell/array/functions
@@ -72,7 +72,7 @@ __sm.array.pop()
local _name _variable index
_name="${1}"
_variable="${2:-}"
- shift || __sm.log.fail "Array name was not given."
+ (( $# )) && shift || __sm.log.fail "Array name was not given."
eval "(( \${#${_name}[@]} ))" || __sm.log.fail "Array '${_name}' was empty."
@@ -89,7 +89,7 @@ __sm.array.shift()
local _name index _variable
_name="${1:-}"
_variable="${2:-}"
- shift || __sm.log.fail "Array name was not given."
+ (( $# )) && shift || __sm.log.fail "Array name was not given."
[[ -z "${_variable}" ]] || eval "${_variable}=\${${_name}[${__sm_array_start}]}"
@@ -100,7 +100,7 @@ __sm.array.unshift()
{
local _name
_name="${1:-}"
- shift || __sm.log.fail "Array name was given."
+ (( $# )) && shift || __sm.log.fail "Array name was given."
local _elements=("$@")
@@ -113,7 +113,7 @@ __sm.array.join()
{
local _name IFS
_name="${1:-}"
- shift || __sm.log.fail "Array name was not given."
+ (( $# )) && shift || __sm.log.fail "Array name was not given."
IFS=${1:-' '}
eval "printf \"\${${_name}[*]}\""
}
@@ -123,7 +123,7 @@ __sm.array.largest()
local _name _index _largest
_name="${1:-}"
_largest=""
- shift || __sm.log.fail "No array variable name was given."
+ (( $# )) && shift || __sm.log.fail "No array variable name was given."
eval "
for (( _index=1 ; _index <= \${#${_name}[@]} ; _index++ ))
@@ -156,7 +156,7 @@ __sm.array.unique()
{
local _name
_name="${1:-}"
- shift || __sm.log.fail "Array variable name was not given."
+ (( $# )) && shift || __sm.log.fail "Array variable name was not given."
eval "${_name}=( \${(u)${_name}[@]} )"
}
View
2 core/internal/shell/config/extensions
@@ -8,7 +8,7 @@ config_extension_setup()
path="${3:-}"
true ${language:=shell}
- shift 3 || __sm.log.fail "Extension name, module name and path must be given."
+ (( $# >=3 )) && shift 3 || __sm.log.fail "Extension name, module name and path must be given."
path create "${extension_path}/config"
file create "${extension_path}/defaults"
View
6 core/internal/shell/database/extensions
@@ -4,11 +4,11 @@ database_extension_setup()
{
local extension module path
extension="${1}"
- shift || __sm.log.fail "Extension must be given as the first parameter."
+ (( $# )) && shift || __sm.log.fail "Extension must be given as the first parameter."
module="${1}"
- shift || __sm.log.fail "Module must be given as the second parameter."
+ (( $# )) && shift || __sm.log.fail "Module must be given as the second parameter."
path="${1}"
- shift || __sm.log.fail "Path must be given as the third parameter."
+ (( $# )) && shift || __sm.log.fail "Path must be given as the third parameter."
paths enter "${path}"
View
4 core/internal/shell/extensions/cache/functions
@@ -96,9 +96,9 @@ __sm.cache.map.find.matching()
{
local _method _name _item
_method="$1"
- shift || __sm.log.fail "No method and action name was given for search"
+ (( $# )) && shift || __sm.log.fail "No method and action name was given for search"
_name="$1"
- shift || __sm.log.fail "No action name was given for search"
+ (( $# )) && shift || __sm.log.fail "No action name was given for search"
for _item in "${_actions_cache[@]}"
do
case "${_method}" in
View
8 core/internal/shell/extensions/common/functions
@@ -4,7 +4,7 @@ __sm.extension.path()
{
local _path extension
extension=$1
- shift || __sm.log.fail "Cannot process extension path;"\
+ (( $# )) && shift || __sm.log.fail "Cannot process extension path;"\
" No extension name was given."
for _path in ${extensions_search_paths[@]}
@@ -22,17 +22,17 @@ __sm.extension.is.valid()
{
local _path
_path="${1:-}"
- shift || __sm.log.fail "No extension path was given to check validity."
+ (( $# )) && shift || __sm.log.fail "No extension path was given to check validity."
[[ -n "${_path}" ]] || __sm.log.fail "Path to the extension was not given."
[[ -d "${_path}/bin" || -d "${_path}/shell" ]]
}
__sm.extension.find()
{
extensions_path="${1:-}" extension="${2:-}"
- shift || __sm.log.fail "Cannot detect extension existence;"\
+ (( $# )) && shift || __sm.log.fail "Cannot detect extension existence;"\
" No extension path was given."
- shift || __sm.log.fail "Cannot detect extension existence;"\
+ (( $# )) && shift || __sm.log.fail "Cannot detect extension existence;"\
" No extension name was given."
__sm.extension.is.valid $extensions_path/$extension
}
View
6 core/internal/shell/extensions/completion/functions
@@ -4,9 +4,9 @@ find_starting_action()
{
trace_filter action_completion || set -o xtrace
extensions_path="$1" extension="$2"
- shift || __sm.log.fail "Cannot detect extension existence;"\
+ (( $# )) && shift || __sm.log.fail "Cannot detect extension existence;"\
" No extension path was given."
- shift || __sm.log.fail "Cannot detect extension existence;"\
+ (( $# )) && shift || __sm.log.fail "Cannot detect extension existence;"\
" No extension name was given."
local _action_params _action_path _new_action_path _rest_params \
@@ -44,7 +44,7 @@ find_starting_action()
show_extension_names()
{
extensions_path="$1"
- shift || __sm.log.fail "no path given"
+ (( $# )) && shift || __sm.log.fail "no path given"
#$1 is ignored == "unused"
local _patern extension
View
8 core/internal/shell/extensions/detection/functions
@@ -8,8 +8,8 @@ __sm.cache.map.check()
_found_actions=()
_method="$1"
_name="$2"
- shift || __sm.log.fail "No method and action name was given for search"
- shift || __sm.log.fail "No action name was given for search"
+ (( $# )) && shift || __sm.log.fail "No method and action name was given for search"
+ (( $# )) && shift || __sm.log.fail "No action name was given for search"
__sm.cache.map.find.matching "${_method}" "${_name}"
@@ -62,8 +62,8 @@ __sm.extension.actions.find()
extensions_path="$1"
extension="$2"
- shift || __sm.log.fail "Extension path must be given as the first parameter."
- shift || __sm.log.fail "Extension name must be given as the second parameter."
+ (( $# )) && shift || __sm.log.fail "Extension path must be given as the first parameter."
+ (( $# )) && shift || __sm.log.fail "Extension name must be given as the second parameter."
local _action_params _action_path _new_action_path _rest_params _param_temp \
_action_params_length _actions_root _map _modules_root _actions_cache
View
14 core/internal/shell/extensions/manipulation/functions
@@ -4,7 +4,7 @@ extension_version()
{
local _extension
_extension=$1
- shift || __sm.log.fail "Cannot retrieve extension version;"\
+ (( $# )) && shift || __sm.log.fail "Cannot retrieve extension version;"\
" No extension was given."
true ${extension_path:="${extensions_path}/${_extension}"}
@@ -69,7 +69,7 @@ __sm.extension.actions()
local _extension _files _file _actions
_extension="${1:-}"
_actions=()
- shift || __sm.log.fail "No extension was given."
+ (( $# )) && shift || __sm.log.fail "No extension was given."
[[ -d "${extension_bin_path}" ]] || return 0
#TODO: build actions cache and use it to display actions
echo "${_actions[@]}"
@@ -83,10 +83,10 @@ __sm.extension.install()
{
local _name _uri _version _identifier
_name="${1:-}"
- shift || __sm.log.fail "No extension name was given."
+ (( $# )) && shift || __sm.log.fail "No extension name was given."
_uri="${1:-}"
- shift || true
+ (( $# )) && shift || true
[[ -n "${_uri}" ]] || _uri=$( __sm.extension.get.uri "${_name}" )
[[ -n "${_uri}" ]] ||
@@ -137,15 +137,15 @@ __sm.extension.installed()
;;
(module|type)
_type="$1"
- shift || __sm.log.fail "An module type must follow the '${_token}' keyword"
+ (( $# )) && shift || __sm.log.fail "An module type must follow the '${_token}' keyword"
;;
(in)
_paths="${1}"
- shift || __sm.log.fail "A path must follow keyword 'in'"
+ (( $# )) && shift || __sm.log.fail "A path must follow keyword 'in'"
;;
(exclude)
_exclude="${1}"
- shift || __sm.log.fail "A string must follow keyword 'exclude'"
+ (( $# )) && shift || __sm.log.fail "A string must follow keyword 'exclude'"
_excludes+=("${_exclude//,/ }")
;;
(*)
View
6 core/internal/shell/files/functions
@@ -4,7 +4,7 @@ __sm.files.source()
{
local _file _files
_files=("$@")
- shift || __sm.log.fail "Cannot source files; No files were given."
+ (( $# )) && shift || __sm.log.fail "Cannot source files; No files were given."
for _file in "${_files[@]}"
do
@@ -54,7 +54,7 @@ __sm.files.remove()
# TODO: add 'from' parameter
local _file _files
_files=("$@")
- shift || __sm.log.fail "Cannot remove files, as no files were given to remove."
+ (( $# )) && shift || __sm.log.fail "Cannot remove files, as no files were given to remove."
for _file in "${_files[@]}"
do
@@ -82,7 +82,7 @@ __sm.files.create()
trace_filter filesystem || set -o xtrace
local _file _path _files
_files=("$@")
- shift || __sm.log.fail "Cannot ensure files exist; No files were given."
+ (( $# )) && shift || __sm.log.fail "Cannot ensure files exist; No files were given."
for _file in "${_files[@]}"
do
View
2 core/internal/shell/os/functions
@@ -4,7 +4,7 @@ __sm.os.open()
{
local _uri
_uri="${1:-}"
- shift || __sm.log.fail "Cannot open URI; No uri was given."
+ (( $# )) && shift || __sm.log.fail "Cannot open URI; No uri was given."
if __sm.command.exists open
then
View
6 core/internal/shell/package/extensions
@@ -7,9 +7,9 @@ package_extension_setup()
module="${2:-}"
path="${3:-}"
true ${language:=shell}
- shift || __sm.log.fail "Cannot setup package extension; no extension name given."
- shift || __sm.log.fail "Cannot setup package extension; no module name given."
- shift || __sm.log.fail "Cannot setup package extension; no path given."
+ (( $# )) && shift || __sm.log.fail "Cannot setup package extension; no extension name given."
+ (( $# )) && shift || __sm.log.fail "Cannot setup package extension; no module name given."
+ (( $# )) && shift || __sm.log.fail "Cannot setup package extension; no path given."
for action in install uninstall update activate deactivate
do
View
8 core/internal/shell/package/functions
@@ -729,8 +729,8 @@ __sm.package.activate.first()
local _package _version
_package="${1:-}"
_version="${2:-}"
- shift || __sm.log.fail "Package name must be given as first parameter."
- shift || __sm.log.fail "Package version must be given as second parameter."
+ (( $# )) && shift || __sm.log.fail "Package name must be given as first parameter."
+ (( $# )) && shift || __sm.log.fail "Package version must be given as second parameter."
if paths exist "${install_path}"
then
@@ -845,7 +845,7 @@ __sm.package.patches.apply()
{
local _patch _patches
_patches=("$@")
- shift || __sm.log.fail "No patches were given."
+ (( $# )) && shift || __sm.log.fail "No patches were given."
for _patch in "${_patches[@]}"
do
@@ -859,7 +859,7 @@ __sm.package.is.active()
local _name _version _path
_name="${1:-}"
_version="${2:-}"
- shift || __sm.log.fail "No package name was given, or name is empty."
+ (( $# )) && shift || __sm.log.fail "No package name was given, or name is empty."
_path="${packages_path}/versions/${_name}"
View
2 core/internal/shell/paths/functions
@@ -174,7 +174,7 @@ __sm.paths.in()
{
local _path
_path="${1:-}"
- shift || __sm.log.fail "Path was not given!"
+ (( $# )) && shift || __sm.log.fail "Path was not given!"
[[ -d "${_path}" ]] || __sm.log.fail "'${_path}' is not a path!"
for dir in "${_path}"/*
View
2 core/internal/shell/processes/functions
@@ -4,7 +4,7 @@ __sm.process.lockfile.lock()
{
local _lockfile
_lockfile="${1:-}"
- shift ||
+ (( $# )) && shift ||
__sm.log.fail "No lockfile was specified as the first parameter."
printf "$$" >> "${_lockfile}" # *Append* current process's pid to the lockfile
View
6 core/internal/shell/service/extensions
@@ -7,9 +7,9 @@ service_extension_setup()
module="${2}"
path="${3}"
true ${language:=shell}
- shift || __sm.log.fail "Extension name not given as first parameter."
- shift || __sm.log.fail "Module name not given as second parameter."
- shift || __sm.log.fail "Path not given as third parameter."
+ (( $# )) && shift || __sm.log.fail "Extension name not given as first parameter."
+ (( $# )) && shift || __sm.log.fail "Module name not given as second parameter."
+ (( $# )) && shift || __sm.log.fail "Path not given as third parameter."
for action in start stop restart status list
do
View
6 core/internal/shell/service/functions
@@ -398,7 +398,7 @@ __sm.service.initd.install()
{
local _service _version
_service="${1:-}"
- shift ||fail "Service name was not passed in as the first parameter"
+ (( $# )) && shift ||fail "Service name was not passed in as the first parameter"
_version="${2:-${package_version}}"
#TODO: WTF ^ why is this $2 after a shift ?
@@ -682,7 +682,7 @@ __sm.service.activate()
{
local _service _version
_service="${1:-"${service}"}"
- shift || __sm.log.fail "The service name must be set or given to activate a service."
+ (( $# )) && shift || __sm.log.fail "The service name must be set or given to activate a service."
_version="${2:-${package_version}}"
#TODO: WTF ^ why use $2 after shift ?
@@ -869,7 +869,7 @@ __sm.service.signal()
local _signal _pid
_signal="${1}"
_pid="${2:-0}"
- shift || __sm.log.fail "Cannot signal service;"\
+ (( $# )) && shift || __sm.log.fail "Cannot signal service;"\
" Signal must be given as the first parameter and be one of:"\
" {KILL,QUIT,TERM,USR1,USR2,TTIN,TTOU,a digit})."
View
2 core/internal/shell/services/functions
@@ -11,7 +11,7 @@ services_list()
{
local _action _args
_action="${1:-}"
- shift || true
+ (( $# )) && shift || true
case "${_action}" in
(active)
View
2 core/internal/shell/steps/functions
@@ -15,7 +15,7 @@ step()
local name
name="$1"
- shift || __sm.log.fail "Cannot take step as no step name given;"\
+ (( $# )) && shift || __sm.log.fail "Cannot take step as no step name given;"\
"step [name] <- missing name."
start_step "$name"
View
10 core/internal/shell/templates/functions
@@ -5,7 +5,7 @@ __sm.templates.find()
local _extensions_path _extension _template_path _params_path
_extensions_path="$1"
- shift || __sm.log.fail "No extensions path and extension name given."
+ (( $# )) && shift || __sm.log.fail "No extensions path and extension name given."
_params_path="$*"
_params_path="${_params_path// //}"
@@ -70,7 +70,7 @@ __sm.templates.seed()
{
local _template _hash _strings temporary
_template="${1:-}"
- shift || __sm.log.fail "No template name was given."
+ (( $# )) && shift || __sm.log.fail "No template name was given."
_hash=("$@")
_strings=()
temporary=${_template}.${timestamp}.$$
@@ -109,13 +109,13 @@ __sm.templates.update()
local _template _target _incoming _hash _strings _variables
_template="${1:-}"
_target="${2:-}"
- shift || __sm.log.fail "Cannot update seed template;"\
+ (( $# )) && shift || __sm.log.fail "Cannot update seed template;"\
" Template name was not given as the first parameter."
- shift || __sm.log.fail "Cannot update seed template;"\
+ (( $# )) && shift || __sm.log.fail "Cannot update seed template;"\
" Template target was not given as the second parameter."
_incoming="${1:-${_target}.incoming}"
- shift || true
+ (( $# )) && shift || true
_hash=("$@")
_strings=()
_variables="${_target}.var.$$"
View
4 core/internal/shell/variables/functions
@@ -5,7 +5,7 @@ __sm.variables.are.nonempty()
trace_filter variables || set -o xtrace
local _variable _variables
_variables=("$@")
- shift || __sm.log.fail "Cannot check if variables are nonempty; No variables were given."
+ (( $# )) && shift || __sm.log.fail "Cannot check if variables are nonempty; No variables were given."
for _variable in "${_variables[@]}"
do
@@ -19,7 +19,7 @@ __sm.variables.are.empty()
trace_filter variables || set -o xtrace
local _variable
_variable="${1:-}"
- shift || __sm.log.fail "Cannot check if variable is empty, as no variable was given."
+ (( $# )) && shift || __sm.log.fail "Cannot check if variable is empty, as no variable was given."
eval "[[ -z \"\${${_variable}:-}\" ]]"
}
View
10 core/internal/shell/vcs/detection/functions
@@ -13,7 +13,7 @@ detect_uri()
{
local extensions_path _uri_path
extensions_path="${1:-}"
- shift || fail "extensions_path must be given as first parameter."
+ (( $# )) && shift || fail "extensions_path must be given as first parameter."
__sm.extension.path.rebuild ".uri" $extensions_path $@
@@ -49,7 +49,7 @@ scm_identifier()
{
local _uri
_uri="${1:-}"
- shift || fail "url must be given as first parameter."
+ (( $# )) && shift || fail "url must be given as first parameter."
if [[ -d "${_uri}" ]]
then
@@ -68,7 +68,7 @@ is_github_uri()
{
local _uri
_uri="${1:-}"
- shift || fail "uri must be given as first parameter."
+ (( $# )) && shift || fail "uri must be given as first parameter."
if __sm.string.ematch "${_uri}" "^[[:alnum:]_-]+\/[[:alnum:]_-]+$"
then
@@ -93,7 +93,7 @@ is_archive_uri()
{
local _uri
_uri="${1:-}"
- shift || fail "uri must be given as first parameter."
+ (( $# )) && shift || fail "uri must be given as first parameter."
case "${_uri}" in
*.tar|*.tgz|*.txz|*.tbz2|*.xz|*.bz2|*.gz|*.zip|*.lzma|*github.com/*/*ball/*)
return 0
@@ -108,7 +108,7 @@ fetch_uri_detect_scm_type()
{
local _uri
_uri="${1:-}"
- shift || fail "uri must be given as first parameter."
+ (( $# )) && shift || fail "uri must be given as first parameter."
if [[ -d "${_uri}" ]] # check for directory
then
View
4 core/internal/shell/vcs/errors/functions
@@ -10,7 +10,7 @@ fetch_error()
{
local _message _pair
_message="${1:-}"
- shift || __sm.log.fail "Message must be given as first parameter."
+ (( $# )) && shift || __sm.log.fail "Message must be given as first parameter."
for _pair in "$@"
do
@@ -32,7 +32,7 @@ fetch_error_default_handler()
{
local _message
_message="${1:-}"
- shift || __sm.log.fail "Message must be given as first parameter."
+ (( $# )) && shift || __sm.log.fail "Message must be given as first parameter."
__vcs_failed="${_message}"
case "${_message}" in
View
22 core/internal/shell/vcs/functions
@@ -26,8 +26,8 @@ fetch_uri()
_uri="${1:-}"
_target="${2:-}"
_args=()
- shift || __sm.log.fail "uri must be specified as the first parameter."
- shift || __sm.log.fail "target path must be specified as the second parameter."
+ (( $# )) && shift || __sm.log.fail "uri must be specified as the first parameter."
+ (( $# )) && shift || __sm.log.fail "target path must be specified as the second parameter."
builtin cd "$initial_pwd"
@@ -78,8 +78,8 @@ fetch_uris()
_uris=( "${1}" )
_target="${2:-}"
_args=()
- shift || __sm.log.fail "uri must be specified as the first parameter."
- shift || __sm.log.fail "target path must be specified as the second parameter."
+ (( $# )) && shift || __sm.log.fail "uri must be specified as the first parameter."
+ (( $# )) && shift || __sm.log.fail "target path must be specified as the second parameter."
fetch_uri_parse_args "$@"
@@ -120,7 +120,7 @@ fetch_uri_parse_args()
case "${_token}" in
(*${_allowed_arg})
eval "${_allowed_arg}=\"${1}\""
- shift || __sm.log.fail "${_allowed_arg} must be specified after '${_token}'."
+ (( $# )) && shift || __sm.log.fail "${_allowed_arg} must be specified after '${_token}'."
continue 2
;;
esac
@@ -129,12 +129,12 @@ fetch_uri_parse_args()
case "${_token}" in
(--on-fail)
fetch_error_handler=$1
- shift || __sm.log.fail "fetch __sm.log.error handler function must be specified after '--on-fail'."
+ (( $# )) && shift || __sm.log.fail "fetch __sm.log.error handler function must be specified after '--on-fail'."
continue
;;
(--fallback-uri)
_uris+=( ${1//,/ } )
- shift || __sm.log.fail "comma separated lit of uris must be specified after '--fallback-uri'."
+ (( $# )) && shift || __sm.log.fail "comma separated lit of uris must be specified after '--fallback-uri'."
continue
;;
esac
@@ -146,7 +146,7 @@ fetch_update()
{
local _uri _target
_target="${1:-}"
- shift || __sm.log.fail "target path must be specified as the second parameter."
+ (( $# )) && shift || __sm.log.fail "target path must be specified as the second parameter."
if [[ -d "${_target}" ]] && [[ -s "${_target}/.uri" ]]
then
@@ -166,15 +166,15 @@ cli_fetch()
_uri="${1:-}"
_target="${2:-}"
_args=()
- shift || __sm.log.error "uri must be specified as the first parameter."
- shift || __sm.log.error "target path must be specified as the second parameter."
+ (( $# )) && shift || __sm.log.error "uri must be specified as the first parameter."
+ (( $# )) && shift || __sm.log.error "target path must be specified as the second parameter."
fetch_uri "${_uri}" "${_target}" --on-fail __sm.log.error "$@"
}
cli_fetch_update()
{
local _target
_target="${1:-}"
- shift || __sm.log.error "target path must be specified as the second parameter."
+ (( $# )) && shift || __sm.log.error "target path must be specified as the second parameter."
fetch_update "${_target}" --on-fail __sm.log.error "$@"
}
View
4 core/internal/shell/vcs/handlers/archive/functions
@@ -12,8 +12,8 @@ archive_get()
_final_target="${2:-}"
_package_md5="${3:-${md5:-#}}"
_archive="${archives_path}/${_uri##*/}"
- shift || __sm.log.fail "uri must be specified as the first parameter."
- shift || __sm.log.fail "target path must be specified as the second parameter."
+ (( $# )) && shift || __sm.log.fail "uri must be specified as the first parameter."
+ (( $# )) && shift || __sm.log.fail "target path must be specified as the second parameter."
case "${_uri}" in
# fix github archive names
View
4 core/internal/shell/vcs/handlers/git/functions
@@ -15,8 +15,8 @@ git_get()
remote=${4:-origin}
revision=${5:-HEAD}
- shift || __sm.log.fail "url must be the first parameter to git_get()."
- shift || __sm.log.fail "target path must be the second parameter to git_get()."
+ (( $# )) && shift || __sm.log.fail "url must be the first parameter to git_get()."
+ (( $# )) && shift || __sm.log.fail "target path must be the second parameter to git_get()."
__sm.command.exists git ||
__sm.log.error "'git' was not found, please install git and try again.\n"\
View
4 core/internal/shell/vcs/handlers/github/functions
@@ -17,8 +17,8 @@ github_get()
_target="${2:-}"
branch=${3:-${branch:-master}}
- shift || __sm.log.fail "uri must be specified as the first parameter."
- shift || __sm.log.fail "target path must be specified as the second parameter."
+ (( $# )) && shift || __sm.log.fail "uri must be specified as the first parameter."
+ (( $# )) && shift || __sm.log.fail "target path must be specified as the second parameter."
save_fetch_error_handler="${fetch_error_handler}"
fetch_error_handler=true
View
4 core/internal/shell/vcs/handlers/hg/functions
@@ -13,8 +13,8 @@ hg_get()
_uri="${1:-}"
_target="${2:-}"
- shift || __sm.log.fail "url must be specified as the first parameter."
- shift || __sm.log.fail "target path must be specified as the second parameter."
+ (( $# )) && shift || __sm.log.fail "url must be specified as the first parameter."
+ (( $# )) && shift || __sm.log.fail "target path must be specified as the second parameter."
if [[ -d "${_target}" ]]
then # TODO: ensure this works...
View
4 core/internal/shell/vcs/handlers/path/functions
@@ -15,8 +15,8 @@ path_get()
_source="${1:-}"
_target="${2:-}"
- shift || __sm.log.fail "source path must be the first parameter to path_get()."
- shift || __sm.log.fail "target path must be the second parameter to path_get()."
+ (( $# )) && shift || __sm.log.fail "source path must be the first parameter to path_get()."
+ (( $# )) && shift || __sm.log.fail "target path must be the second parameter to path_get()."
if rm -rf "${_target}" > /dev/null 2>&1
then
View
4 core/internal/shell/vcs/handlers/svn/functions
@@ -13,8 +13,8 @@ svn_get()
_uri="${1:-}"
_target="${2:-}"
- shift || __sm.log.fail "url must be specified as the first parameter."
- shift || __sm.log.fail "target path must be specified as the second parameter."
+ (( $# )) && shift || __sm.log.fail "url must be specified as the first parameter."
+ (( $# )) && shift || __sm.log.fail "target path must be specified as the second parameter."
if [[ -d "${_target}" ]]
then # TODO: ensure this works...
View
22 core/sm/shell/log/functions
@@ -385,7 +385,7 @@ __sm.log.trace.filter()
{
local old _name _action
_action="$1"
- shift || __sm.log.fail "Filter action {start,stop} must be specified."
+ (( $# )) && shift || __sm.log.fail "Filter action {start,stop} must be specified."
case "${_action}" in
start)
@@ -405,7 +405,7 @@ __sm.log.trace.filter()
if [[ "${_name}" == "${old}" ]]
then
- shift || true
+ (( $# )) && shift || true
__sm_trace_filter_stack=( "$@" )
fi
;;
@@ -440,7 +440,7 @@ __sm.log.debug()
{
local type
type="$1"
- shift || __sm.log.fail "Debug type must be given as the first parameter."
+ (( $# )) && shift || __sm.log.fail "Debug type must be given as the first parameter."
if (( debug_flag )) && __sm.log.options.check "$debug_flags" "$type"
then
@@ -462,8 +462,8 @@ __sm.log.search()
local name value
name="${1:-}"
value="${2:-}"
- shift || __sm.log.fail "name must be given as the first parameter."
- shift || __sm.log.fail "value must be given as the second parameter."
+ (( $# )) && shift || __sm.log.fail "name must be given as the first parameter."
+ (( $# )) && shift || __sm.log.fail "value must be given as the second parameter."
if (( debug_flag )) && __sm.log.options.check "$debug_flags" "search"
then
@@ -485,7 +485,7 @@ __sm.actions.source()
{
local script
script="$1"
- shift || __sm.log.fail "No script was given as the first parameter."
+ (( $# )) && shift || __sm.log.fail "No script was given as the first parameter."
[[ -r "$script" ]] || __sm.log.fail "Could not find script to run: $script."
trace_filter action || set -o xtrace
source "$script"
@@ -634,7 +634,7 @@ __sm.log.rotate()
{
local _file _tail_pid
_file="${1:-}"
- shift || __sm.log.fail "Cannot rotate a log file, as no log file was given."
+ (( $# )) && shift || __sm.log.fail "Cannot rotate a log file, as no log file was given."
timestamp="$( date +"%Y-%m-%dT%H:%M:%S" )"
@@ -678,19 +678,19 @@ __sm.log.streams()
;;
err)
_stderr="${1}"
- shift || __sm.log.fail "stderr name must follow keyword 'err'"
+ (( $# )) && shift || __sm.log.fail "stderr name must follow keyword 'err'"
;;
out)
_stdout="${1}"
- shift || __sm.log.fail "stdout name must follow keyword 'out'"
+ (( $# )) && shift || __sm.log.fail "stdout name must follow keyword 'out'"
;;
mix)
_stdmix="${1}"
- shift || __sm.log.fail "stdmix name must follow keyword 'mix'"
+ (( $# )) && shift || __sm.log.fail "stdmix name must follow keyword 'mix'"
;;
*)
_command="${1}"
- shift || __sm.log.fail "A command must be given in order to log it's streams."
+ (( $# )) && shift || __sm.log.fail "A command must be given in order to log it's streams."
;;
esac
done
View
10 core/sm/shell/modules/functions
@@ -236,7 +236,7 @@ __sm.extension.in.paths()
{
local callback _path
callback="${1:-}"
- shift || __sm.log.fail "Callback name must be given ast the first parameter."
+ (( $# )) && shift || __sm.log.fail "Callback name must be given ast the first parameter."
if [[ -n "$1" ]] # do search if params given
then
@@ -253,7 +253,7 @@ __sm.cli.in.path()
{
local callback
callback="${1:-}"
- shift || __sm.log.fail "Callback name must be given ast the first parameter."
+ (( $# )) && shift || __sm.log.fail "Callback name must be given ast the first parameter."
"${callback}" "${sm_path}/core" "cli" "$@"
}
@@ -264,7 +264,7 @@ __sm.extension.path.reorder()
part="${1:-}"
extensions_path="${2:-}"
extension="${3:-}"
- shift 3 || __sm.log.fail "Path part extensions_path extnesion must be given first ."
+ (( $# >= 3 )) && shift 3 || __sm.log.fail "Path part extensions_path extnesion must be given first ."
output="$extensions_path/$extension/$part/$*"
rebuilded_path="${output// //}"
@@ -275,7 +275,7 @@ __sm.extension.path.rebuild()
local part extensions_path params
part="$1"
extensions_path="$2"
- shift 2 || __sm.log.fail "Path extensions_path part must be given first."
+ (( $# >= 2 )) && shift 2 || __sm.log.fail "Path extensions_path part must be given first."
params="$*"
__sm.extension.path.reorder "${part}" "${extensions_path}" ${=params//\// }
@@ -285,7 +285,7 @@ __sm.module.detect()
{
local extensions_path _module_path
extensions_path=$1
- shift || __sm.log.fail "Extensions path must be given as the first parameter."
+ (( $# )) && shift || __sm.log.fail "Extensions path must be given as the first parameter."
__sm.extension.path.rebuild "shell" $extensions_path $@
_module_path=${rebuilded_path}
View
18 core/sm/shell/versionedfs/functions
@@ -48,7 +48,7 @@ versionedfs()
local _token _path _paths _source _name _version _strategy _method _activate _action
_action="${1:-}"
- shift || __sm.log.fail "Usage: versionedfs path \"{versionedfs root path}\" "\
+ (( $# )) && shift || __sm.log.fail "Usage: versionedfs path \"{versionedfs root path}\" "\
"strategy \"{fhs,name}\" method \"{link,copy}\" activate \"{newest,first}\""
while (( $# ))
@@ -57,47 +57,47 @@ versionedfs()
case "${_token}" in
(path)
_path="${1}"
- shift || __sm.log.fail "versionedfs path must follow keyword 'path'"
+ (( $# )) && shift || __sm.log.fail "versionedfs path must follow keyword 'path'"
;;
(source)
_source="${1}"
- shift || __sm.log.fail "Source path must follow keyword 'source'"
+ (( $# )) && shift || __sm.log.fail "Source path must follow keyword 'source'"
;;
(name)
_name="${1}"
- shift || __sm.log.fail "Name must follow keyword 'name'"
+ (( $# )) && shift || __sm.log.fail "Name must follow keyword 'name'"
;;
(version)
_version="${1}"
- shift || __sm.log.fail "Version string must follow keyword 'version'"
+ (( $# )) && shift || __sm.log.fail "Version string must follow keyword 'version'"
;;
(strategy)
_strategy="${1}"
- shift || __sm.log.fail "Strategy string must follow keyword 'strategy'"
+ (( $# )) && shift || __sm.log.fail "Strategy string must follow keyword 'strategy'"
case "${_strategy}" in
(fhs|name) true ;;
(*) __sm.log.fail "Strategy must be one of {fhs,name}" ;;
esac
;;