aboutsummaryrefslogtreecommitdiff
path: root/bin/csmw.awk
blob: b1cd20cb26af1653c73920809a3c52577728814e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Print an English comma-separated list of monospace-quoted words (backticks)
{
    for (i = 1; i <= NF; i++)
        ws[++wc] = $i
}
END {
    if (wc > 2)
        for (i = 1; i <= wc; i++)
            printf (i < wc) ? "`%s`, " : "and `%s`\n", ws[i]
    else if (wc == 2)
        printf "`%s` and `%s`\n", ws[1], ws[2]
    else if (wc == 1)
        printf "`%s`\n", ws[1]
}