Subject: Re: strange tab printing problem
To: None <netbsd-help@netbsd.org>
From: Jukka Salmi <j+nbsd@2006.salmi.ch>
List: netbsd-help
Date: 03/21/2006 23:59:04
Seems that the message with the script attached was filtered after
being accepted by mail.netbsd.org... So here is the script "inline":

$ cat tab.sh
#!/bin/sh

size=$(stty size) || exit
cols=${size#* }

i=1
while [ $i -lt $cols ]; do printf '.'; i=$(($i+1)); done

printf '\tXYZ\n'
#        ^ this tab character is not printed!

# end of script


Answering the two replies:

$ echo $TERM
xterm

$ stty size
24 80
... but this doesn't matter, I can reproduce the problem with any
column count I tried so far.

stty(1) prints `-oxtabs' unless I am logged in with ssh or telnet, in
which case it prints `oxtabs'... That probably explains the problem.


Regards, Jukka

Jukka Salmi --> netbsd-help (2006-03-21 17:42:57 +0100):
> Hi,
> 
> this is probably a bug somewhere in NetBSD, but since I have no idea
> where exactly it could be I post this message here...
> 
> Running the attached script should print some dots, followed by a tab,
> followed by "XYZ". However, on the -current NetBSD/i386 system I'm
> currently using, the tab is not printed. Actually, it doesn't matter
> how many tabs I print before "XYZ" with that last printf statement -
> none of them is output.
> 
> On a terminal window with 80 columns this looks as follows:
> 
> $ ./tab.sh
> ...............................................................................X
> YZ
> 
> Note that the 'X' follows the last dot; there's no tab in between.
> 
> In case this is not strange enough: if I use ssh(1) or telnet(1) to
> connect to the same host I'm already logged into, running the script
> suddenly works as expected:
> 
> $ telnet moray
> [...]
> $ ./tab.sh
> ............................................................................... 
> XYZ
> 
> 
> Hmm, any hints about what could be wrong?
> 
> TIA, Jukka
> 
> -- 
> bashian roulette:
> $ ((RANDOM%6)) || rm -rf ~

-- 
bashian roulette:
$ ((RANDOM%6)) || rm -rf ~