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 was archived by the owner on Apr 26, 2024. It is now read-only.
Sometimes it can be extremely convenient to have them and having a simple example would help. Also it might help to show some broken behavior of IFS=\n, which can be very surprising.
# https://stackoverflow.com/a/53747300
s='A|B|C|D'# specify your "array" as a string with a sigil between elements
IFS='|'# specify separator between elementsset -f # disable glob expansion, so a * doesn't get replaced with a list of filesgetNth() { shift"$(($1+1))";printf'%s\n'"$1"; }
getLast() { getNth "$(( $(length "$@") -1))""$@"; }
length() { echo"$#"; }
length $s# emits 4
getNth 0 $s# emits A
getNth 1 $s# emits B
getLast $s# emits D
s2='t1 t2 t3 t4'set -f; IFS=''# IFS='\n' appears to be brokenforjarin${s2};doset +f;unset IFS
echo"$jar"# restore globbing and field splitting at all whitespacedoneset +f;unset IFS # do it again in case $INPUT was emptyecho"done"