Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #224842

Re: delimiters with more than one character? ...

From Greg Wooledge <wooledg@eeg.ccf.org>
Newsgroups linux.debian.user
Subject Re: delimiters with more than one character? ...
Date 2020-07-15 14:50 +0200
Message-ID <AsP1f-1P9-11@gated-at.bofh.it> (permalink)
References <AssHn-5be-3@gated-at.bofh.it> <Asv2y-6Hp-7@gated-at.bofh.it> <Asv2y-6Hp-5@gated-at.bofh.it> <AsMPL-Ai-3@gated-at.bofh.it> <AsORA-1Lw-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, Jul 15, 2020 at 08:34:36AM -0400, Bob Weber wrote:
> My only purpose was to show how tr could be used to handle multiple
> characters as a delimiter either as tr -s '\\\|' '\|' or

The problem is, it can't, at least not the way you showed.  The original
example, sadly, did NOT contain instances of the | and \ characters in
isolation, so one might be lulled into a false sense of security, and
write code that (for example) simply deletes all of the \ characters,
and then splits on the | characters.

But that won't work in the general case, where | and \ might appear as
literal data characters.

My own solution, which involved using awk to convert the \| pairs into
NUL bytes, is also technically incorrect.  However, there was an
additional stipulation: the stream was to be converted into a bash
array.  A bash array is a list of C strings, so they cannot contain
NUL bytes.  Therefore you can't possibly have NUL bytes in the original
input stream (at least, not and still produce a bash array), so my
conversion of the multi-character delimiters into NUL bytes will "work".

But it's a freaking ugly problem any way you look at it, and it just
got uglier when it was revealed that the OP might be trying to write
shell code that parses shell code.  Especially if the code in question
is a series of poorly written GNU-tainted grep commands.

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

delimiters with more than one character? ... Albretch Mueller <lbrtchx@gmail.com> - 2020-07-14 15:00 +0200
  Re: delimiters with more than one character? ... Alex Mestiashvili <amestia@rsh2.donotuse.de> - 2020-07-14 15:00 +0200
    Re: delimiters with more than one character? ... Greg Wooledge <wooledg@eeg.ccf.org> - 2020-07-14 15:10 +0200
      Re: delimiters with more than one character? ... Nicolas George <george@nsup.org> - 2020-07-14 15:10 +0200
      Re: delimiters with more than one character? ... Alex Mestiashvili <amestia@rsh2.donotuse.de> - 2020-07-14 15:20 +0200
  Re: delimiters with more than one character? ... Greg Wooledge <wooledg@eeg.ccf.org> - 2020-07-14 15:10 +0200
  Re: delimiters with more than one character? ... Nicolas George <george@nsup.org> - 2020-07-14 15:20 +0200
  Re: delimiters with more than one character? ... Nicolas George <george@nsup.org> - 2020-07-14 17:30 +0200
    Re: delimiters with more than one character? ... Albretch Mueller <lbrtchx@gmail.com> - 2020-07-15 12:30 +0200
      Re: delimiters with more than one character? ... Greg Wooledge <wooledg@eeg.ccf.org> - 2020-07-15 14:00 +0200
      Re: delimiters with more than one character? ... David Wright <deblis@lionunicorn.co.uk> - 2020-07-15 14:30 +0200
      Re: delimiters with more than one character? ... Bob Weber <bobrweber@gmail.com> - 2020-07-15 14:40 +0200
        Re: delimiters with more than one character? ... Greg Wooledge <wooledg@eeg.ccf.org> - 2020-07-15 14:50 +0200
          Re: delimiters with more than one character? ... Bob Weber <bobrweber@gmail.com> - 2020-07-15 16:20 +0200
            Re: delimiters with more than one character? ... Greg Wooledge <wooledg@eeg.ccf.org> - 2020-07-15 16:30 +0200
            Re: delimiters with more than one character? ... The Wanderer <wanderer@fastmail.fm> - 2020-07-15 16:30 +0200
            Re: delimiters with more than one character? ... Nicolas George <george@nsup.org> - 2020-07-15 17:50 +0200
        Re: delimiters with more than one character? ... Nicolas George <george@nsup.org> - 2020-07-15 15:10 +0200
  Re: delimiters with more than one character? ... Bob Weber <bobrweber@gmail.com> - 2020-07-14 17:30 +0200
  Re: delimiters with more than one character? ... Alessandro Baggi <alessandro.baggi@gmail.com> - 2020-07-15 17:30 +0200
  Re: delimiters with more than one character? ... Eric S Fraga <e.fraga@ucl.ac.uk> - 2020-07-16 12:10 +0200
    Re: delimiters with more than one character? ... "Thomas Schmitt" <scdbackup@gmx.net> - 2020-07-16 13:40 +0200
      Re: delimiters with more than one character? ... Greg Wooledge <wooledg@eeg.ccf.org> - 2020-07-16 14:00 +0200
        Re: delimiters with more than one character? ... Greg Wooledge <wooledg@eeg.ccf.org> - 2020-07-16 16:00 +0200
          Re: delimiters with more than one character? ... Zenaan Harkness <zenaan@freedbms.net> - 2020-07-17 04:50 +0200
            Re: delimiters with more than one character? ... Nicolas George <george@nsup.org> - 2020-07-17 10:50 +0200
              Re: delimiters with more than one character? ... rhkramer@gmail.com - 2020-07-17 13:20 +0200
                tmpfs is not a ramdisk (was: delimiters with more than one  character? ...) Nicolas George <george@nsup.org> - 2020-07-17 13:30 +0200
                Re: tmpfs is not a ramdisk (was: delimiters with more than one  character? ...) David Wright <deblis@lionunicorn.co.uk> - 2020-07-17 18:20 +0200
                Re: tmpfs is not a ramdisk (was: delimiters with more than one character? ...) rhkramer@gmail.com - 2020-07-17 20:30 +0200
                Re: tmpfs is not a ramdisk (was: delimiters with more than one  character? ...) Zenaan Harkness <zenaan@freedbms.net> - 2020-07-18 07:20 +0200
                Re: tmpfs is not a ramdisk (was: delimiters with more than one  character? ...) <tomas@tuxteam.de> - 2020-07-18 10:40 +0200
                Re: delimiters with more than one character? ... Greg Wooledge <wooledg@eeg.ccf.org> - 2020-07-17 13:40 +0200
        Re: delimiters with more than one character? ... "Thomas Schmitt" <scdbackup@gmx.net> - 2020-07-16 16:00 +0200
        Re: delimiters with more than one character? ... Zenaan Harkness <zenaan@freedbms.net> - 2020-07-17 04:50 +0200
      Re: delimiters with more than one character? ... Eric S Fraga <e.fraga@ucl.ac.uk> - 2020-07-16 15:00 +0200
  Re: delimiters with more than one character? ... John Crawley <john@bunsenlabs.org> - 2020-08-05 08:30 +0200
    Re: delimiters with more than one character? ... Greg Wooledge <wooledg@eeg.ccf.org> - 2020-08-05 15:10 +0200
      Re: delimiters with more than one character? ... John Crawley <john@bunsenlabs.org> - 2020-08-06 05:00 +0200
        Re: delimiters with more than one character? ... Greg Wooledge <wooledg@eeg.ccf.org> - 2020-08-06 13:40 +0200
          Re: delimiters with more than one character? ... John Crawley <john@bunsenlabs.org> - 2020-08-07 03:10 +0200

csiph-web