Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

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