aboutsummaryrefslogblamecommitdiff
path: root/bin/csmw.awk
blob: 351fc74934c8416625730cf8310e2c1342e03aad (plain) (tree)
1
2
3
4
5
6
7
8
9
                                                                             
                

                             
                             


               
                                 
                                                        
                     
                                          
                     
                            
 
# Print an English comma-separated list of monospace-quoted words (backticks)
BEGIN { wc = 0 }
{
    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]
}