You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
This function works as intended in >= 3.1, unless I'm forgetting something. Prior to 3.1, you'll likely incorrectly see single-quotes in the output, if it even gets that far.
Tested on all full releases of BASH, from 3.0 to 5.1.8.
My approach would be:
split() {
IFS=$1read -a Buffer <<<"$2"printf'%s\n'"${Buffer[@]}"
}
It's even more portable, available in at least >= 3.0. The original is considerably convoluted, in my opinion.
One thing worth keeping in mind is that a here string in BASH returns an empty line if a null value is given to it, because of the newline character BASH adds after the fact, but given the nature of this function, I don't think that's a problem here.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
https://github.com/dylanaraps/pure-bash-bible#split-a-string-on-a-delimiter
This function works as intended in >= 3.1, unless I'm forgetting something. Prior to 3.1, you'll likely incorrectly see single-quotes in the output, if it even gets that far.
Tested on all full releases of BASH, from 3.0 to 5.1.8.
My approach would be:
It's even more portable, available in at least >= 3.0. The original is considerably convoluted, in my opinion.
One thing worth keeping in mind is that a here string in BASH returns an empty line if a null value is given to it, because of the newline character BASH adds after the fact, but given the nature of this function, I don't think that's a problem here.
The text was updated successfully, but these errors were encountered: