Print escape character in os_log parameter renders incorrectly in Terminal

Originator:scottberrevoets
Number:rdar://33975849 Date Originated:18-Aug-2017 08:46 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 9 beta 5
Classification:UI/Usability Reproducible:Always
 
Summary:
When printing the escape character (ASCII 033) in os_log through a parameter, the output in Terminal (using `log`) is not <nothing>, but `\[`. When printing this character directly from the message, this works fine. This breaks printing ANSI colors in Terminal for os_log parameters.

Steps to Reproduce:
- Run attached project in simulator
- In Terminal, run $ log stream --predicate 'subsystem == "OSLogTest"'

Expected Results:
Both printed strings are red

Actual Results:
Only the second string is red, presumably because it was part of the original message and not a formatted parameter.

Version:
Xcode 9 beta 5

Notes:

Comments

Please know that our engineering team has determined that this issue behaves as intended based on the information provided.

libtrace intentionally escapes control characters. This is by design to avoid security issues.

Makes sense.

By scottberrevoets at Aug. 23, 2017, 8:37 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!