bug-bash
[Top][All Lists]
Advanced

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

Re: printf width format specifier doesn't work when assigned


From: microsuxx
Subject: Re: printf width format specifier doesn't work when assigned
Date: Sat, 25 Jan 2025 15:35:34 +0100

the \* to * works also
leftover of testing
.. needs set -f

On Sat, Jan 25, 2025, 3:34 PM microsuxx <fxmbsw7@gmail.com> wrote:

> ~ $ set -f
> ~ $ foo=$(printf "%*s\n" 80 " " | tr " " "*") ; echo $foo
>
> ********************************************************************************
>
> ~ $ printf -v v '%*s' 200 ' ' ; v=${v// /\*} ; echo $v
> ********************************************************************************************************************************************************************************************************
>
> On Sat, Jan 25, 2025, 2:41 PM Ross <ross@smith-bath.co.uk> wrote:
>
>>
>> Configuration Information [Automatically generated, do not change]:
>> Machine: x86_64
>> OS: linux-gnu
>> Compiler: gcc
>> Compilation CFLAGS: -g -O2 -fno-omit-frame-pointer -mno-omit-leaf-
>> frame-pointer -flto=auto -ffat-lto-objects -fstack-protector-strong -
>> fstack-clash-protection -Wformat -Werror=format-security -fcf-
>> protection -Wall
>> uname output: Linux X220-Bravo 6.8.0-51-generic #52-Ubuntu SMP
>> PREEMPT_DYNAMIC Thu Dec  5 13:09:44 UTC 2024 x86_64 x86_64 x86_64
>> GNU/Linux
>> Machine Type: x86_64-pc-linux-gnu
>>
>> Bash Version: 5.2
>> Patch Level: 21
>> Release Status: release
>>
>> Description:
>> From the command line
>>     printf "%*s\n" 80 " " | tr " " "*"
>> does just what I'd expect generating a banner line of asterisks.
>>
>> However:
>>     foo=$(printf "%*s\n" 80 " " | tr " " "*")
>>     echo $foo
>> acts very differently; it seems to perform ls or something similar.
>>
>> The same occurs with the more standard printf "%80s" form.
>>
>> Repeat-By:
>> As above.
>>
>> Fix:
>> Unknown.
>>
>>
>>


reply via email to

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