help-bash
[Top][All Lists]
Advanced

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

Re: string escaping in bash


From: Alex fxmbsw7 Ratchev
Subject: Re: string escaping in bash
Date: Fri, 12 Mar 2021 22:41:34 +0100

thank you

i may post a new version soon whenever i succeed it, i just gotta think
more about it

thank you again

On Fri, Mar 12, 2021 at 10:37 PM Lawrence Velázquez <vq@larryv.me> wrote:

> > On Mar 12, 2021, at 3:25 PM, Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com>
> wrote:
> >
> > this is without keep over and does the stupid non edge cases
> > maybe you can give me better test cases ?
> >
> > i=-1 res=( ) list=( '\one' '\\Two' '\\\Three' '\\\\four' '\\\\\five' )
> > right=( '\one' '\Two' '\\Three' '\\four' '\\\five' ) ; for str in
> > "${list[@]}" ; do str=${str//\\n/$'\n'} str=${str//\\t/$'\t'}
> > res[++i]=${str//\\\\/\\} ; printf '%d %s %s\n' $i "${res[i]}"
> "${right[i]}"
> > ; done
>
>         bash-5.1$ str='\\n'
>         bash-5.1$ printf '%s' "$str" | od -A n -t a -t x1
>                    \   \   n
>                    5c  5c  6e
>
> This should become '\n' (0x5c 0x6e).
>
>         bash-5.1$ str=${str//\\n/$'\n'}
>         bash-5.1$ str=${str//\\t/$'\t'}
>         bash-5.1$ str=${str//\\\\/\\}
>         bash-5.1$ printf '%s' "$str" | od -A n -t a -t x1
>                    \  nl
>                    5c  0a
>
> --
> vq
>
>


reply via email to

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