summaryrefslogtreecommitdiff
path: root/dictloop
blob: 1a239ea172e2a216ba9e627dc1e682909a0abfc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh
# Script for checking multiple definitions one after another

# Load aliases if available
if [ -n "$ZDOTDIR" ] && [ -f "$ZDOTDIR/aliasrc" ]; then
    . "$ZDOTDIR/aliasrc"
fi

# Argument check
if [ "$#" -ne 1 ]; then
    echo "Usage: dictloop <dict>" >&2
    exit 1
fi

dict=$1

while :; do
    printf "Enter a word: "
    read -r word

    if [ -z "$word" ] || [ "$word" = "exit" ]; then
        echo "Exiting..."
        exit 0
    fi

    "$dict" "$word"
done