Unrar Behavior During Terminal Resizing
This article explains how the unrar command-line utility
behaves when a terminal window is resized during an archive extraction.
While the core file decompression and writing processes continue
uninterrupted, the program's console output often suffers from visual
formatting glitches because unrar does not actively redraw
or reformat its standard output stream to accommodate dynamic window
dimensions.
Signal Handling and Core Execution
When a terminal window is resized, the operating system kernel sends
a SIGWINCH (Window Change) signal to the active foreground
process. Advanced terminal applications built with libraries like
ncurses catch this signal to calculate new window bounds
and repaint the user interface.
The standard unrar utility does not implement an active
dynamic redraw mechanism for SIGWINCH. Because terminal
window changes do not terminate the process, the background extraction
logic remains completely unaffected:
- Decompression Integrity: Data decompression runs without pauses or errors.
- File System Operations: Files continue to write to disk normally.
- Exit Codes: The operation will exit with standard success or failure codes regardless of window adjustments.
Visual Output and Artifacting
The primary impact of resizing a terminal during an
unrar extraction is visual. By default, unrar
prints extraction progress, file names, and percentages using carriage
returns (\r) to overwrite the current line in standard
output rather than scrolling continuously.
When the terminal size changes mid-operation:
- Shrinking the Terminal Width: If the terminal width
becomes narrower than the line of text being printed, the terminal
emulator forces the text to wrap onto a new line. When
unrarissues a subsequent carriage return to update the progress percentage, it only returns to the start of the current wrapped line rather than the original line. This causes repeated, cascading lines of progress output and cluttered text on the screen. - Expanding the Terminal Width: If the terminal is
widened, previously wrapped lines do not automatically unwrap.
Furthermore, because
unrardoes not issue terminal clear sequences, shorter output lines may leave "ghost" characters from longer, previously printed lines visible on the right side of the screen.
Suppressing Display Issues
To prevent display artifacts during automated tasks or environments
where window resizing is frequent, you can control unrar's
verbosity using built-in switches:
- Disable percentage indicators: Using the
-idpswitch disables the dynamic percentage indicator while still displaying extracted filenames, reducing line-overwrite issues. - Quiet mode: Using the
-idqswitch restricts output to basic messages. - Complete silence: Using the
-inulswitch suppresses all console messages, directing errors strictly through process return codes.