kshutils/diralias

33 lines
515 B
Plaintext
Raw Normal View History

function diralias
{
typeset -i i=0
case $# in
0)
while (( i < ${#DIRALIASNAM[@]} ))
do
printf "%s\t%s\n" ${DIRALIASNAM[i]} "${DIRALIASVAL[i]}"
let i++
done
;;
1)
while [[ $i -lt ${#DIRALIASNAM[@]} && $1 != ${DIRALIASNAM[i]} ]]
do
let i++
done
(( i == ${#DIRALIASNAM[@]} )) && print $1 || print ${DIRALIASVAL[i]}
;;
2)
while [[ $i -lt ${#DIRALIASNAM[@]} && $1 != ${DIRALIASNAM[i]} ]]
do
let i++
done
DIRALIASNAM[i]=$1
DIRALIASVAL[i]="$2"
;;
*)
exit 64
;;
esac
}