1#! /bin/bash
2#
3# zprintf - function that calls gawk to do printf for those systems that
4#	    don't have a printf executable
5#
6# The format and arguments can have trailing commas, just like gawk
7#
8# example:
9#	zprintf 'Eat %x %x and suck %x!\n' 57005 48879 64206
10#
11# Chet Ramey
12# chet@po.cwru.edu
13
14[ $# -lt 1 ] && {
15	echo "zprintf: usage: zprintf format [args ...]" >&2
16	exit 2
17}
18
19fmt="${1%,}"
20shift
21
22for a in "$@"; do
23	args="$args,\"${a%,}\""
24done
25
26gawk "BEGIN { printf \"$fmt\" $args }"
27