Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eend 0 does effectively nothing, so let's remove it #229

Closed
adrelanos opened this issue Oct 23, 2023 · 0 comments · Fixed by #230
Closed

eend 0 does effectively nothing, so let's remove it #229

adrelanos opened this issue Oct 23, 2023 · 0 comments · Fixed by #230

Comments

@adrelanos
Copy link
Contributor

eend() {
  local retval="${1:-0}"
  shift
  if [ "$retval" -gt 0 ]; then
    printf " %s-> Failed (rc=%s)%s\\n" "${BAD}" "${retval}" "${NORMAL}"
  fi
  return "$retval"
}

eend 0 just results in return 0 which doesn't do anything.

In preparation of #224 for code simplification it would be best to remove these.

A very few cases are a tiny bit more complex.

      if cp "$AUTHORIZED_KEYS_SOURCE" "$AUTHORIZED_KEYS_TARGET" ; then
        eend 0
      else
        eerror "Error: copying '$AUTHORIZED_KEYS_SOURCE' to '$AUTHORIZED_KEYS_TARGET' failed"
        eend 1
        bailout 1
      fi

Could rewrite to:

      if ! cp "$AUTHORIZED_KEYS_SOURCE" "$AUTHORIZED_KEYS_TARGET" ; then
        eerror "Error: copying '$AUTHORIZED_KEYS_SOURCE' to '$AUTHORIZED_KEYS_TARGET' failed"
        eend 1
        bailout 1
      fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant