null bytes after ANSI sequences in color 'ls' output

Thomas Dickey dickey at radix.net
Sat Jun 28 11:39:59 UTC 2008


On Fri, Jun 27, 2008 at 07:45:52PM -0700, Mike Brown wrote:
> After I upgraded 6.2-STABLE (Feb 2007-ish) to 6.3-STABLE (last week), my 
> colorized 'ls -G' output is now plagued with 8 null bytes following each ANSI 
> sequence.
> 
> I normally pipe my output to 'less -R' so ANSI sequences pass through while 
> other control characters are converted to visible ones. This worked great 
> until now. Now I see '^@' for each null. It's not a new feature of less, so
> I assume it's ls or curses throwing in the nulls.
> 
> For example, I'm getting output like this if I use 'ls -G | less':
> 
> ESC[36mMailESC[39;49mESC[mESC[m^@^@^@^@^@^@^@^@
> 
> It's the '^@'s that are unexpected, although the repeated ESC[m pairs are also 
> mysterious since they seem to have no purpose.

It's possible that an application could be sending padding characters
(nulls).  The vt100-color terminal description inherits from vt100,
which does use padding - but in the sf/sr (scroll forward/reverse).

Real vt100's require padding (emulators generally do not ;-).

That's the termcap, looking at a not-very-recent copy.

If your terminal description came in part from terminfo, ncurses'
terminfo for vt100 has padding for several features, which can be
disabled for curses apps by setting NCURSES_NO_PADDING in the
environment.

However, I suspect that "ls" is just using termcap features, so that
environment variable may have no effect (depends on what "ls" does
with the termcap string, to write it to the terminal).

But it's something to check/try.
 
> If I use 'ls -G | less -R', then the ANSI sequences pass through as they 
> should, but I still get the nulls.
> 
> 
> Questions:
> 
> Is this is reproducible?
> Should I file a PR?
> 
> FWIW, my tcsh TERM environment variable is vt100-color.
> I'm using SecureCRT with vt100 emulation and ANSI color. 
> 
> Thanks,
> Mike
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"

-- 
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20080628/e34c7d91/attachment.pgp


More information about the freebsd-questions mailing list