bash aesthetics question: special characters in reg exp in [[ ... =~~ ... ]]

Liste des GroupesRevenir à cu shell 
Sujet : bash aesthetics question: special characters in reg exp in [[ ... =~~ ... ]]
De : gazelle (at) *nospam* shell.xmission.com (Kenny McCormack)
Groupes : comp.unix.shell
Date : 22. Jul 2024, 22:59:11
Autres entêtes
Organisation : The official candy of the new Millennium
Message-ID : <v7mknf$3plab$1@news.xmission.com>
User-Agent : trn 4.0-test77 (Sep 1, 2010)
Note: this is just a question of aesthetics.  Functionally, it all works as
expected.

Sample bash code:

    f="$(fortune)" # Get some multi-line output into "f"
    # Look for foo followed by bar on the same line
    [[ "$f" =~ foo[^$'\n']*bar ]] && echo "foo bar"

The point is you need the "anything other than a newline" or else it might
match foo on one line and bar on a later line.  The above is the only way I
could figure out to express a newline in the particular flavor of reg exps
used by the =~ operator.

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".

Is there any way to get this?

--
Shikata ga nai...

Date Sujet#  Auteur
22 Jul 24 * bash aesthetics question: special characters in reg exp in [[ ... =~~ ... ]]19Kenny McCormack
23 Jul 24 +* Re: bash aesthetics question: special characters in reg exp in [[ ... =~~ ... ]]9Kaz Kylheku
23 Jul 24 i`* Re: bash aesthetics question: special characters in reg exp in [[ ... =~~ ... ]]8Janis Papanagnou
23 Jul 24 i +* Re: bash aesthetics question: special characters in reg exp in [[ ... =~~ ... ]]6Kenny McCormack
23 Jul 24 i i`* Re: bash aesthetics question: special characters in reg exp in [[ ... =~~ ... ]]5Janis Papanagnou
23 Jul 24 i i `* Re: bash aesthetics question: special characters in reg exp in [[ ... =~~ ... ]]4Kenny McCormack
23 Jul 24 i i  `* Re: bash aesthetics question: special characters in reg exp in [[ ... =~~ ... ]]3Janis Papanagnou
23 Jul 24 i i   `* Re: bash aesthetics question: special characters in reg exp in [[ ... =~~ ... ]]2Kenny McCormack
24 Jul 24 i i    `- Re: bash aesthetics question: special characters in reg exp in [[ ... =~~ ... ]]1Janis Papanagnou
23 Jul 24 i `- Re: bash aesthetics question: special characters in reg exp in [[ ... =~~ ... ]]1Kaz Kylheku
23 Jul 24 `* Re: bash aesthetics question: special characters in reg exp in [[ ... =~~ ... ]]9Arti F. Idiot
23 Jul 24  `* Re: bash aesthetics question: special characters in reg exp in [[ ... =~~ ... ]]8Kenny McCormack
23 Jul 24   `* Re: bash aesthetics question: special characters in reg exp in [[ ... =~~ ... ]]7Kaz Kylheku
24 Jul 24    +* Re: bash aesthetics question: special characters in reg exp in [[ ... =~~ ... ]]5Ben Bacarisse
24 Jul 24    i`* Re: bash aesthetics question: special characters in reg exp in [[ ... =~~ ... ]]4Kaz Kylheku
24 Jul 24    i `* Re: bash aesthetics question: special characters in reg exp in [[ ... =~~ ... ]]3Ben Bacarisse
24 Jul 24    i  `* Re: bash aesthetics question: special characters in reg exp in [[ ... =~~ ... ]]2Kaz Kylheku
24 Jul 24    i   `- Re: bash aesthetics question: special characters in reg exp in [[ ... =~~ ... ]]1Ben Bacarisse
24 Jul 24    `- Re: bash aesthetics question: special characters in reg exp in [[ ... =~~ ... ]]1Janis Papanagnou

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal