Deutsch English Français Italiano |
<v7nu8t$15bon$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Janis Papanagnou <janis_papanagnou+ng@hotmail.com> Newsgroups: comp.unix.shell Subject: Re: bash aesthetics question: special characters in reg exp in [[ ... =~~ ... ]] Date: Tue, 23 Jul 2024 11:48:11 +0200 Organization: A noiseless patient Spider Lines: 57 Message-ID: <v7nu8t$15bon$1@dont-email.me> References: <v7mknf$3plab$1@news.xmission.com> <20240722153843.823@kylheku.com> MIME-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Tue, 23 Jul 2024 11:48:13 +0200 (CEST) Injection-Info: dont-email.me; posting-host="813c436e4ebdd14f30c57dbc5b95f784"; logging-data="1224471"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19fcp+b4Oczh8OV68RlWweW" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 Cancel-Lock: sha1:0Xujtjr1ywjeT0yuttfHv/PNbxw= In-Reply-To: <20240722153843.823@kylheku.com> X-Enigmail-Draft-Status: N1110 Bytes: 2534 On 23.07.2024 00:47, Kaz Kylheku wrote: > 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? Of course (and out of curiosity) I tried that display detail as well in Kornshell to see how it behaves, and using a different command to display it... With my (old?) bash: $ f() { [[ "$f" =~ foo[^$'\n']*bar ]] && echo "foo bar" ; } $ typeset -f f f () { [[ "$f" =~ foo[^' ']*bar ]] && echo "foo bar" } The same with ksh: $ f() { [[ "$f" =~ foo[^$'\n']*bar ]] && echo "foo bar" ; } $ typeset -f f f() { [[ "$f" =~ foo[^$'\n']*bar ]] && echo "foo bar" ; } And for good measure also in zsh: % f() { [[ "$f" =~ foo[^$'\n']*bar ]] && echo "foo bar" ; } % typeset -f f f () { [[ "$f" =~ foo[^$'\n']*bar ]] && echo "foo bar" } Both seem to show "better aesthetics". Too bad it doesn't help for your bash context. Janis > [...]