help-bash
[Top][All Lists]
Advanced

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

Re: `printf %q` but more human readable


From: Alex fxmbsw7 Ratchev
Subject: Re: `printf %q` but more human readable
Date: Sun, 14 Mar 2021 15:54:48 +0100

well yes, two things
1) gawk is a data processing language
but yes it should be internal
bash has it partly
if array elements contain \34 it ( declare -p ) shows $'..' otherwise its
double quoted, .. yet i havent seen no quotes usage yet

On Sun, Mar 14, 2021 at 3:52 PM Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com>
wrote:

> sounds to me like a [too] big thing to code
> a tokenizer to internal codes then to output format
>
> On Sun, Mar 14, 2021 at 3:48 PM Peng Yu <pengyu.ut@gmail.com> wrote:
>
>> On 3/14/21, Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com> wrote:
>> > about self coding a solution, i started in gawk, but question: do you
>> want
>> > \t and \n be shortened or printed
>>
>> I am not sure. That is where the ambiguity comes from. It will depend
>> on the real usage. If the string's main purpose is to show tab and
>> newline explicitly, then they should be encoded in an escaped form,
>> but if the main purpose is not to show them, then they should not be
>> escaped. But this is context-dependent. So it may need some trial and
>> error to be sure which choice is the best. Or it may need to
>> empirically determine which is the case based on the content of the
>> whole string.
>>
>> > and only \34 codes be placed in $' .. '
>> > otherwise " " otherwise no quotes
>>
>> It is more than these three cases. '' is also useful in certain cases.
>> Also, sometimes, splitting the whole string into segments and use a
>> different style for each segment may also improve readability.
>>
>> --
>> Regards,
>> Peng
>>
>


reply via email to

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