Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Printf builtin missing v flag support
- X-seq: zsh-workers 37462
- From: "Starms, William Albert (MU-Student)" <williamstarms@xxxxxxxxxxxxxxxxx>
- To: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Subject: Printf builtin missing v flag support
- Date: Thu, 31 Dec 2015 07:16:00 +0000
- Accept-language: en-US
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=williamstarms@xxxxxxxxxxxxxxxxx;
- In-reply-to: <etPan.5684d3d1.74f2df6b.31ec@Ganymede>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <etPan.5684d3d1.74f2df6b.31ec@Ganymede>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:23
- Thread-index: AQHRQ5sZy95IbbcY90WA9GVX8CRFnQ==
- Thread-topic: Printf builtin missing v flag support
I had a script malfunctioning on me and printing “-v” to stdout, and I found that it’s because zsh (version 5.2) doesn’t seem to support the v flag that bash has. I did some digging through GNU's bash source and it seems to have been added somewhere between 3.0 and 3.1. According to the bash documentation:
printf: printf [-v var] format [arguments]
...
If the -v option is supplied, the output is placed into the value of the
shell variable VAR rather than being sent to the standard output.
Is this just a feature that nobody noticed/cared about, or was there a reason for its omission? I couldn’t find anything on the subject, but I may just be bad at googling. I know printf can just be run in a subshell and captured, but forking for this seems like overkill, I say without any knowledge of the zsh backend.
For posterity, here’s the offending line: printf -v hexch "%02X" "'$ch”
It’s part of an Apple bash script to update the terminal titlebar on a wd change.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author