33 lines
609 B
Plaintext
33 lines
609 B
Plaintext
|
function nsalias {
|
||
|
typeset -i i=0
|
||
|
|
||
|
case $# in
|
||
|
0|1)
|
||
|
while (( i < ${#NSCMDNS[@]} ))
|
||
|
do
|
||
|
[[ ( -z $1 ) || ( ${NSCMDNS[i]} = $1 ) ]] \
|
||
|
&& print -c "${NSCMDNS[i]}\t${NSCMDFN[i]}\t${NSCMDSH[i]}"
|
||
|
let i++
|
||
|
done
|
||
|
;;
|
||
|
2)
|
||
|
while [[ $i -lt ${#NSCMDNS[@]} && ( ${NSCMDNS[i]} != $1 || ${NSCMDFN[i]} != $2 ) ]]
|
||
|
do
|
||
|
let i++
|
||
|
done
|
||
|
(( i == ${#NSCMDNS[@]} )) && return 1
|
||
|
eval "${NSCMDSH[i]}"
|
||
|
;;
|
||
|
3)
|
||
|
(( $# != 3 )) && return 64
|
||
|
NSCMDNS[${#NSCMDNS[@]}]=$1
|
||
|
NSCMDFN[${#NSCMDFN[@]}]=$2
|
||
|
NSCMDSH[${#NSCMDSH[@]}]=$3
|
||
|
! alias $1 >/dev/null && alias $1="nsalias $1"
|
||
|
;;
|
||
|
*)
|
||
|
return 64
|
||
|
;;
|
||
|
esac
|
||
|
}
|