Path: ...!news.misty.com!2.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Kaz Kylheku <643-408-1753@kylheku.com> Newsgroups: comp.unix.shell Subject: Re: bash aesthetics question: special characters in reg exp in [[ ... =~~ ... ]] Date: Mon, 22 Jul 2024 22:47:59 -0000 (UTC) Organization: A noiseless patient Spider Lines: 32 Message-ID: <20240722153843.823@kylheku.com> References: Injection-Date: Tue, 23 Jul 2024 00:47:59 +0200 (CEST) Injection-Info: dont-email.me; posting-host="2e723cea1cdfb5e1d326eb8834436c3e"; logging-data="905595"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+1fVJwQlogdm9xdTmW2ND4nLt5p3PubtQ=" User-Agent: slrn/pre1.0.4-9 (Linux) Cancel-Lock: sha1:f8IvrQ5x6wcl/YEBOFZpaJGFDDw= Bytes: 2010 On 2024-07-22, Kenny McCormack 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/txr Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal Mastodon: @Kazinator@mstdn.ca