Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Cyborg)
  • No Skin
Collapse
Brand Logo

CIRCLE WITH A DOT

  1. Home
  2. Uncategorized
  3. I found an odd shell bug & I'm not entirely sure who's at fault.

I found an odd shell bug & I'm not entirely sure who's at fault.

Scheduled Pinned Locked Moved Uncategorized
7 Posts 5 Posters 0 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • hanno@mastodon.socialH This user is from outside of this forum
    hanno@mastodon.socialH This user is from outside of this forum
    hanno@mastodon.social
    wrote last edited by
    #1

    I found an odd shell bug & I'm not entirely sure who's at fault. Some interaction between screen, ANSI colors & grep seems to make a char disappear.
    Reproducer: run this in screen on a terminal with 80 chars width:
    echo -e 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx12345'|grep 234
    The "4" disappears mysteriously... Seems to be caused by escape code '[K' from grep. I'd appreciate explanations+whether I should report a bug to screen, grep or elsewhere.

    Link Preview Image
    hanno@mastodon.socialH jmorahan@mastodon.ieJ wr@infosec.exchangeW 3 Replies Last reply
    0
    • hanno@mastodon.socialH hanno@mastodon.social

      I found an odd shell bug & I'm not entirely sure who's at fault. Some interaction between screen, ANSI colors & grep seems to make a char disappear.
      Reproducer: run this in screen on a terminal with 80 chars width:
      echo -e 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx12345'|grep 234
      The "4" disappears mysteriously... Seems to be caused by escape code '[K' from grep. I'd appreciate explanations+whether I should report a bug to screen, grep or elsewhere.

      Link Preview Image
      hanno@mastodon.socialH This user is from outside of this forum
      hanno@mastodon.socialH This user is from outside of this forum
      hanno@mastodon.social
      wrote last edited by
      #2

      Possibly related, but slightly different issue: if I do this in xterm, but not in screen, the 4 also disappears, but it's not replaced by empty space, but by the 5 (which should end up on the next line)

      Link Preview Image
      uint8_t@chaos.socialU qbi@freie-re.deQ 2 Replies Last reply
      0
      • hanno@mastodon.socialH hanno@mastodon.social

        Possibly related, but slightly different issue: if I do this in xterm, but not in screen, the 4 also disappears, but it's not replaced by empty space, but by the 5 (which should end up on the next line)

        Link Preview Image
        uint8_t@chaos.socialU This user is from outside of this forum
        uint8_t@chaos.socialU This user is from outside of this forum
        uint8_t@chaos.social
        wrote last edited by
        #3

        @hanno what if you pipe to grep 4 the output? is the 4 in the pipe or already eaten by grep?

        hanno@mastodon.socialH 1 Reply Last reply
        0
        • uint8_t@chaos.socialU uint8_t@chaos.social

          @hanno what if you pipe to grep 4 the output? is the 4 in the pipe or already eaten by grep?

          hanno@mastodon.socialH This user is from outside of this forum
          hanno@mastodon.socialH This user is from outside of this forum
          hanno@mastodon.social
          wrote last edited by
          #4

          @uint8_t same result with only grepping 4. 4 is in the output. Minimal ANSI escape code PoC without grep looks like this:
          echo -e 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1234\033[K5'

          1 Reply Last reply
          0
          • hanno@mastodon.socialH hanno@mastodon.social

            Possibly related, but slightly different issue: if I do this in xterm, but not in screen, the 4 also disappears, but it's not replaced by empty space, but by the 5 (which should end up on the next line)

            Link Preview Image
            qbi@freie-re.deQ This user is from outside of this forum
            qbi@freie-re.deQ This user is from outside of this forum
            qbi@freie-re.de
            wrote last edited by
            #5

            @hanno If I do this in tmux in xterm, the 4 "reappears".

            1 Reply Last reply
            0
            • hanno@mastodon.socialH hanno@mastodon.social

              I found an odd shell bug & I'm not entirely sure who's at fault. Some interaction between screen, ANSI colors & grep seems to make a char disappear.
              Reproducer: run this in screen on a terminal with 80 chars width:
              echo -e 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx12345'|grep 234
              The "4" disappears mysteriously... Seems to be caused by escape code '[K' from grep. I'd appreciate explanations+whether I should report a bug to screen, grep or elsewhere.

              Link Preview Image
              jmorahan@mastodon.ieJ This user is from outside of this forum
              jmorahan@mastodon.ieJ This user is from outside of this forum
              jmorahan@mastodon.ie
              wrote last edited by
              #6

              @hanno https://debbugs.gnu.org/cgi/bugreport.cgi?bug=15444

              1 Reply Last reply
              0
              • hanno@mastodon.socialH hanno@mastodon.social

                I found an odd shell bug & I'm not entirely sure who's at fault. Some interaction between screen, ANSI colors & grep seems to make a char disappear.
                Reproducer: run this in screen on a terminal with 80 chars width:
                echo -e 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx12345'|grep 234
                The "4" disappears mysteriously... Seems to be caused by escape code '[K' from grep. I'd appreciate explanations+whether I should report a bug to screen, grep or elsewhere.

                Link Preview Image
                wr@infosec.exchangeW This user is from outside of this forum
                wr@infosec.exchangeW This user is from outside of this forum
                wr@infosec.exchange
                wrote last edited by
                #7

                @hanno Here are a few other examples of disappearing text, the resulting effect depends on the terminal emulator you use. Here on xfce4-terminal (and bash):

                $ echo -e "blabla\033\0135blibli\n\n\n" | hexdump -C
                00000000 62 6c 61 62 6c 61 1b 5d 62 6c 69 62 6c 69 0a 0a |blabla.]blibli..|
                00000010 0a 0a |..|
                00000012
                $ echo -e "blabla\033\0135blibli\n\n\n"
                blabla$ echo -e "blabla\033\0135blibli\n\n\n" | grep bli
                blabla$
                $
                $ echo -e "blabla\n\033\0135blibli\n\n\n" | hexdump -C
                00000000 62 6c 61 62 6c 61 0a 1b 5d 62 6c 69 62 6c 69 0a |blabla..]blibli.|
                00000010 0a 0a 0a |...|
                00000013
                $ echo -e "blabla\n\033\0135blibli\n\n\n"
                blabla
                $ echo -e "blabla\n\033\0135blibli\n\n\n" | grep bli
                $
                $ echo -e "blabla\033\0135\nblibli\n\n\n" | hexdump -C
                00000000 62 6c 61 62 6c 61 1b 5d 0a 62 6c 69 62 6c 69 0a |blabla.].blibli.|
                00000010 0a 0a 0a |...|
                00000013
                $ echo -e "blabla\033\0135\nblibli\n\n\n"
                blabla$ echo -e "blabla\033\0135\nblibli\n\n\n" | grep bli
                blibli
                $
                $ echo -e "blabla\033\n\0135blibli\n\n\n" | hexdump -C
                00000000 62 6c 61 62 6c 61 1b 0a 5d 62 6c 69 62 6c 69 0a |blabla..]blibli.|
                00000010 0a 0a 0a |...|
                00000013
                $ echo -e "blabla\033\n\0135blibli\n\n\n"
                blabla
                $ echo -e "blabla\033\n\0135blibli\n\n\n" | grep bli
                ]blibli
                $

                That's the trick I used for https://github.com/fuxx/GPG-ANSI-Art-Injector/blob/main/designs/fake_key_summary.py and https://codeberg.org/wllm-rbnt/hacklu-2025-CLI-ambush/

                1 Reply Last reply
                1
                0
                • R relay@relay.infosec.exchange shared this topic
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups