sdushantha / tmpsms

A temporary SMS utility right from your terminal written in POSIX sh
MIT License
1.04k stars 45 forks source link

Why depend on fzf? #5

Closed glennj closed 3 years ago

glennj commented 3 years ago

I find it odd that you use a POSIX sh but depend on fzf. If you write for bash, you can replace

    SELECTION=$(printf %b "$PHONE_NUMBERS" | $FZF_COMMAND)

with

    nums=()
    while IFS= read -r num; do
        nums+=("$num")
    done < <(printf %b "$PHONE_NUMBERS")
    PS3='Select a phone number: '
    select SELECTION in "${nums[@]}" quit; do
        if [[ $SELECTION == 'quit' ]]; then
            SELECTION=""
            break
        elif [[ $SELECTION ]]; then
            break
        fi
    done

That works with bash v3.2.57 and up.

sdushantha commented 3 years ago

From my knowledge, using an external command does not make a script, not POSIX compliant. I quite like the code you have come up with for the selection of the phone numbers, but fzf has a nicer interface in my opinion. Let's say that you want to see US numbers only. You could simply type "US" into the prompt of fzf and you would only be presented with US numbers.