tag 28985 notabug
close 28985
stop

On 24/10/17 19:21, Chris King-Parra wrote:
> Package:             coreutils
> Version:             8.28
> 
> Hi there,
> 
> I was reading the info pages for ``expand`` this afternoon and came across the
> 
> ``--tabs`` option. To my understanding, you supply it with a comma separated
> 
> list of numbers. Each number specifies how many spaces to replace the next
> 
> occurrence of a tab with.  The ``/`` character can be used to prefix a number,
> 
> which will then be used for the number of spaces to expand to for every tab in
> 
> and after that occurrence.
> 
> Here's an excerpt of an example from the info page, describing the ``--tabs=``
> 
> option:
> 
>>  As a GNU extension the last tab specified can be prefixed with a ‘/’ to
> 
> indicate a tab size to use for remaining positions. For example, --tabs=2,4,/8
> 
> will set tab stops at position 2 and 4, and every multiple of 8 after that.
> 
> The results weren’t what I expected::
> 
>     chris@tw-vm:~> echo 'one        |two    |three  |' | expand --tabs=2,4,/8 
> | sed 's/ /#/g' | cat -A
> 
>     one#|two########|three##|$
> 
> For the sake of clarity, here’s the exact command output I expected::
> 
>     chris@tw-vm:~> echo 'one        |two    |three  |' | expand --tabs=2,4,/8 
> | sed 's/ /#/g' | cat -A
> 
>     one#|two####|three########|$
> 
> Here is some other unexpected, but less specific, behavior::
> 
>     chris@tw-vm:~> echo 'one        |two    |three  |' | expand --tabs=1,2,4 
> | sed 's/ /#/g' | cat -A
> 
>     one#|two#|three#|$
> 
> Which I expected to result in::
> 
>     one#|two##|three####|$
> 
> Did I find a bug?

I don't think so.
The following should be instructive.
The uppercase letters are the tab stops,
and you can see the spaces aligning to those.

2,4,/8 ≡ 2,4,8,16,24, so

  $ printf '%s\n' 'aBcDefgHijklmnoPqrstuvwXyz' $'one\t|two\t|three\t|' |
    expand --tabs=2,4,8,16,24 | sed 's/ /#/g' | cat -A

  aBcDefgHijklmnoPqrstuvwXyz$
  one#|two########|three##|$

cheers,
Pádraig



Reply via email to