[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bash doesn't display tabs for tabs -- ignores tabstops.

From: Linda Walsh
Subject: bash doesn't display tabs for tabs -- ignores tabstops.
Date: Sun, 21 Apr 2013 00:25:20 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv: Gecko/20100228 Lightning/0.9 Thunderbird/ Mnenhy/

I don't use it that often, but only recently discovered
that linux compat terminals can set their tabstops.

So one can set tabstops to match their code-indentation --
this allows the benefit of letting others be able
to change tab stops if they want more or less indenting
(vs. using space+tabs, -- if they want to look at code
in their preferred indent level, they would need to reformat
the source code -- a minor bit, but it's a place where
I noted BASH doesn't seem compliant.

If I 'reedit my last "statement", it indents 8 spaces/tab.

However, if I take the same source and "cat it to the terminal",
I get the actual tab stops used on the terminal.

Bash shouldn't force it's idea of tab expansion by ignoring
the terminal's tabstops (and if it can't read the tabstops-
just using the actual tab character is sufficient).

Example -- here's my code as expanded by echo:

while read fn;do
  cd "$d" && {
   if [[ -e $base.exe ]] ;then
    mv "$base.exe" "$d.exe" && ln -s "$d.exe" "$base.exe"
   cp * ../bin
However, this is what one sees if the re-edit the line:
Ishtar:/> echo 'while read fn;do
                cd "$d" && {
                        if [[ -e $base.exe ]] ;then
                                mv "$base.exe" "$d.exe" && ln -s "$d.exe"
                        cp * ../bin
The above echo line produced the 1st shown output -- because bash isn't
using real tabstops -- but is expanding them into spaces for display, though
the re-edited, upon execution display as in the 1st example.

Note, if you have a linux-compat terminal (or try this on you linux
console:  You can use this little script to set your tabs:
> more tty_tab 

#console_codes(4) man page...
printf -v sts "\033H"
if (($#==0)) ; then
  echo "$0: <n>" - set tab stop to N
  exit 1
declare -i tab=$1;
declare -i pos=1
while ((++pos<80)) ;do
  if ((pos%tab)); then str+=" "
  else str+="$sts"
echo -e "\033c"
echo  "$str"

Could bash use 'real tabs' instead of substituting spaces?
(Either that or have a way to set tab expansion.  Note that the
linux console can set tabstops to arbitrary columns (they don't
have to be regularly spaced)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]