From 3f6c1435a4cbdf73a65639b05898a01c0dfc21ac Mon Sep 17 00:00:00 2001 From: Pete Travis Date: Wed, 1 Oct 2014 11:33:51 -0600 Subject: we might need this sles10 stuff later --- .../bash-3.1-postpatch/examples/scripts/zprintf | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 scratch/bash-3.1-postpatch/examples/scripts/zprintf (limited to 'scratch/bash-3.1-postpatch/examples/scripts/zprintf') diff --git a/scratch/bash-3.1-postpatch/examples/scripts/zprintf b/scratch/bash-3.1-postpatch/examples/scripts/zprintf new file mode 100755 index 0000000..5e2e3ad --- /dev/null +++ b/scratch/bash-3.1-postpatch/examples/scripts/zprintf @@ -0,0 +1,26 @@ +#! /bin/bash +# +# zprintf - function that calls gawk to do printf for those systems that +# don't have a printf executable +# +# The format and arguments can have trailing commas, just like gawk +# +# example: +# zprintf 'Eat %x %x and suck %x!\n' 57005 48879 64206 +# +# Chet Ramey +# chet@po.cwru.edu + +[ $# -lt 1 ] && { + echo "zprintf: usage: zprintf format [args ...]" >&2 + exit 2 +} + +fmt="${1%,}" +shift + +for a in "$@"; do + args="$args,\"${a%,}\"" +done + +gawk "BEGIN { printf \"$fmt\" $args }" -- cgit