TransWikia.com

Prevent ^ chars leaking out of variable

Unix & Linux Asked by JoBe on March 5, 2021

I think my script halts because the text it’s about to display contains "commands"

A code that displays the first 20 lines of a subtitles file:

junknownsub=$(head -20 "$f")
zenity --question  --text="$jsubtitlennIs this English?nn$junknownsub"  --width=200 --height=200

this is the text:

0
00:00:00,000 --> 00:00:18,338
<b><font color="#909090">^.^.^.^.movie .^.^.^.^</font></b>
<b><font color="#804040">®</font></b> <b><font color=#ff0000> </font></b> <b><font color="#804040">®</font></b>

This causes linux to popup this question: popup

I suspect it’s the < >^ chars that’s messing things up, because all "normal" text works without any issues..

Anyway to work around this?

a previous suggestion I got was:
printf -v junknownsub '%q' $(head -n20 "$f")
but that only froze nemo

One Answer

Some dialogs displayed by GNOME Zenity support the pango markup language and, by default, interpret it in the dialog text. zenity is parsing the text in your sample as invalid pango markup. It is not a shell issue.

To prevent this you can:

  • Use the --no-markup option. As a downside, the markup will be shown literally, including the n sequences you are using to format the dialog text.
  • Pre-process your subtitle text to remove the markup.

Correct answer by fra-san on March 5, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP