Sujet : Re: bash aesthetics question: special characters in reg exp in [[ ... =~~ ... ]]
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.unix.shellDate : 23. Jul 2024, 00:47:59
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240722153843.823@kylheku.com>
References : 1
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2024-07-22, Kenny McCormack <
gazelle@shell.xmission.com> wrote:
The problem is that if the above is in a function, when you list out the
function with "type funName", the \n has already been digested and
converted to a hard newline. This makes the listing look strange. I'd
rather see "\n".
I see what you mean:
$ test() { [[ "$f" =~ foo[^$'\n']*bar ]] && echo "foo bar" ; }
$ set | grep -A 4 '^test'
test ()
{
[[ "$f" =~ foo[^'
']*bar ]] && echo "foo bar"
}
Is there any way to get this?
Patch Bash so that when it's listing code, any items that need '...'
quoting and that contain control characters are printed as $'...'
syntax with escape sequences.
Someone who had their original code as '
' will might not want that. It has to be an option.
If Bash stored a bit in the code indicating "this word was produced
using $ syntax", then it could be recovered accordingly.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca