Skip to content

Dealing with zsh and newlines in list items #6

@ykonstant1

Description

@ykonstant1

Hello! I came across fun.sh while browsing for functional add-ons to shell scripting. Your functions seem to be the most comprehensive list of functional add-ons to bash (rather than implementing another shell) and I like them very much!

For my use cases, I have a couple of questions/observations, particularly regarding irregular data in shell variables, and how your functions deal with them.

  1. From a couple of tests, basic functions seem to work fine with my shell, zsh. I know bash and zsh are incompatible in subtle ways, so are there any caveats for using your functions with zsh (as far as you know)? Edit: it does seem there are problems in zsh. factorial 4 works under bash, but not under zsh. This is unfortunate :(
  2. Unfortunately, it seems that your functions assume newline-separated words. For example, list $'Hi\nthere' $'Bye\nthere' | map 'echo $1' prints four lines; this behavior creates serious issues with filenames that contain newlines (trailing newlines, even), something that is ubiquitous in my profession (researchers tend to name pdfs by their titles, for instance). Is there an easy way to modify the functions to accept null-separated records, or otherwise behave properly with binary data? A similar issue occurs simply when individual text records contain newlines as part of their formatting. For example, we have a poem, and we want to shuffle around the individual stanzas; these should be individual records containing several newlines each. If your functions could be modified to deal with these situations nicely, please let me know!

Thanks for your time!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions