bug-bash
[Top][All Lists]
Advanced

[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:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666

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
 d=${fn%.zip}
 (
  cd "$d" && {
   base=${d%-*}
   if [[ -e $base.exe ]] ;then
    mv "$base.exe" "$d.exe" && ln -s "$d.exe" "$base.exe"
   fi
   cp * ../bin
  }
 )
done
However, this is what one sees if the re-edit the line:
Ishtar:/> echo 'while read fn;do
        d=${fn%.zip}
        (
                cd "$d" && {
                        base=${d%-*}
                        if [[ -e $base.exe ]] ;then
                                mv "$base.exe" "$d.exe" && ln -s "$d.exe"
"$base.exe"
                        fi
                        cp * ../bin
                }
        )
done'
---
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 

#!/bin/bash
#console_codes(4) man page...
printf -v sts "\033H"
if (($#==0)) ; then
  echo "$0: <n>" - set tab stop to N
  exit 1
fi
declare -i tab=$1;
str=""
declare -i pos=1
while ((++pos<80)) ;do
  if ((pos%tab)); then str+=" "
  else str+="$sts"
  fi
done
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)

Thanks...
-l



reply via email to

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