oils-for-unix / oils

Oils is our upgrade path from bash to a better language and runtime. It's also for Python and JavaScript users who avoid shell!
http://www.oilshell.org/
Other
2.84k stars 157 forks source link

Implement `string.split()` #2048

Closed PossiblyAShrub closed 2 months ago

PossiblyAShrub commented 2 months ago

See design discussion on zulip: https://oilshell.zulipchat.com/#narrow/stream/447377-api-design/topic/API.20design.20-.20shSplit.28.29.20split.28.29.20splitlines.28.29

TODOs:

PossiblyAShrub commented 2 months ago

This is ready for a review.

PossiblyAShrub commented 2 months ago

This is ready for another review.

andychu commented 2 months ago

Merged, thank you!

andychu commented 2 months ago

BTW I am thinking that shSplit() is "discouraged" -- because the algorithm is fiddly and possibly slow -- and the regex is more general than IFS

So split(s) can be an alias for s.split() for convenience

and without any second arg, it will do the whitespace splitting

I think whitespace splitting as a regex has some unicode issues, but it might just work, and if not we can do non-Unicode to start (since I think this function will be extremely commonly used)