[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Feature Request: Python-like string split and join

From: Koichi Murase
Subject: Re: Feature Request: Python-like string split and join
Date: Sun, 24 Jan 2021 11:29:46 +0800

2021年1月24日(日) 10:22 William Park <opengeometry@yahoo.ca>:
> [...]  But, if separator is string, then it gets messy.

I agree that the split by a (multi-character) string is one of the
non-trivial operations in the current Bash.

> We shouldn't have to resort to Awk/Python for that.

I think a typical reply in this list to this kind of request is just
"use Awk/Python". Bash doesn't aim to be a language for writing real
programs, so usually you should write the entire program in another
language. That said, I feel splitting/joining with a string separator
is useful and primitive enough.

> How about Python-like string split and string join?

What does "Python-like" mean? Is it special compare to common
split/join in typical programming languages?

>     ${parameter...;sep}

Is there a background for choosing a semicolon to split words? Zsh has
a similar feature with a different syntax:


Actually, we can think of dozens of fancy string operations found in
other languages, and the split or the join is merely one of such
operations. For example, Zsh has about 50 different flags modifying
the expansion results ( see
). We cannot prepare different syntaxes for each of these possible 50
operations, so the question is whether the split/join is so important
and essential compared to other possible string operations that it
deserves to occupy the semicolon.

Recent Bash rather has the parameter expansion form of ${param@flags},
so, if it would be implemented, I guess something like


would be a more moderate choice.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]