Skip to content

string replace drops NUL and following text #8468

Closed

Description

@imcaizheng

Version

fish, version 3.3.1

Expectation

$ echo text | string replace 'ex' \0es | tr '\0' '\n'
t
est

Actual Result

$ echo text | string replace 'ex' \0es | tr '\0' '\n'
tt

Related Issues

  1. string escape drops NUL and following text
  2. Nul char causes unexpected result even on command line. For example, echo 1\0"2" outputs 1 instead of 12

Activity

  1. faho commented on Nov 21, 2021

    @faho
    Member

    NUL chars cannot be passed as arguments. Your \0es is effectively an empty argument.

    This is a general UNIX thing - you can't call e.g. grep \0es. We could special-case builtins here, but so far we haven't done so, because there's typically little use in doing that - you don't just add NULs all over the place, because many things can't handle NULs.

  2. imcaizheng commented on Nov 21, 2021

    @imcaizheng
    Author

    @faho Thanks for the clarification! I think this issue can be closed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions