[openbeos] Re: J

"Alan Ellis" <alan@xxxxxxxxxxxxxx> wrote:
> That's super flippin' cool!

Yep, that's true BeOS fun. :-)

> 2 bugs.
> 
> If you have N choices, and you choose N + 1, then it takes you to /
> boot/home.

> You cant jump to a dir with a space in it's name.

A bit ugly though, but that should fix both:

function goThere() {
echo $1
    if [ -d "$1" ] ; then
            cd "$1"
            return $?
        fi
    return 1
}

function countArgs() {
        return $#
}

function j() {
choices=$(query "name=\"$1\"" | tr '\n' ' ')
eval "countArgs $choices"
case $? in
    0) return 1;;
    1) eval "goThere $choices" ; return $?;;
    *)   PS3='Choice: '
         eval "\
         select curChoice in ${choices};\
         do\
            goThere \"\$curChoice\";\
            if [ \$? -eq 0 ];\
            then\
                break;\
            fi;\
        done"
esac
}   

CU, Ingo


Other related posts: