Last active
December 21, 2015 19:08
-
-
Save unakatsuo/6351683 to your computer and use it in GitHub Desktop.
bash rename/alias function.
This file contains hidden or 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
#!/bin/bash | |
function alias_function(){ | |
[[ $(type -t "$1") = 'function' ]] || return 1; | |
local buf | |
buf="function ${2}()" | |
buf="${buf} $(declare -f "${1}" | tail -n +2)" | |
eval "$buf" | |
} | |
function a() | |
{ | |
echo "BK" | |
} | |
alias_function 'a' 'b' | |
echo $? | |
type -t b | |
b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment