-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve readability & complexity by nvm_has_non_aliased()
- Loading branch information
1 parent
6ed73b0
commit feabe9f
Showing
2 changed files
with
56 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/sh | ||
|
||
cleanup () { unalias foo; unalias grep; } | ||
die () { echo "$@" ; cleanup ; exit 1; } | ||
|
||
\. ../../../nvm.sh | ||
|
||
alias foo='bar' | ||
! nvm_has_non_aliased foo || die '"nvm_has_non_aliased foo" was not true' | ||
|
||
alias grep='grep' | ||
unalias grep || die '"unalias grep" failed' | ||
nvm_has_non_aliased grep || die '"nvm_has_non_aliased grep" with unaliased grep was not false' | ||
|
||
alias grep='grep' | ||
! nvm_has_non_aliased grep || die '"nvm_is_alias grep" with aliased grep was not true' | ||
|
||
nvm_has_non_aliased cat && type cat > /dev/null || die 'nvm_has_non_aliased locates "cat" properly' | ||
|
||
[ "~$(nvm_has_non_aliased foobarbaz 2>&1)" = "~" ] || die "nvm_has_non_aliased does not suppress error output" | ||
|
||
! nvm_has_non_aliased foobarbaz && ! type foobarbaz >/dev/null 2>&1 || die "nvm_has_non_aliased does not return a nonzero exit code when not found" | ||
|
||
cleanup |