Skip to content

etc/config.sh/aliases: Error with unalias wmRefresh #12

Description

@d-kirsten

We use Lmod which sources the file with set -e. It aborts when it encounters line 78:

# Refresh the environment
# ~~~~~~~~~~~~~~~~~~~~~~~
# For backward-compatibility unalias wmRefresh if it is defined as an alias
if command -V wmRefresh 2> /dev/null | head -1 | grep -q "function"
then
unset wmRefresh
else
unalias wmRefresh 2> /dev/null
fi

The issue is that wmRefresh can be neither a function nor an alias but the if statement only checks for a function. unalias is then called even if wmRefresh doesn't exist.

It would be very kind if this could be rewritten. At least version 9 is also affected.

If a non-zero exit status matters then maybe something like:

if cmd="$(command -V wmRefresh 2>/dev/null)"
then
    cmd="$(echo "${cmd}" | head -1)"
    case "${cmd}" in
    *function*) unset wmRefresh ;;
    *alias*) unalias wmRefresh ;;
    esac
fi
unset cmd

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions