Skip to content

Instantly share code, notes, and snippets.

@ormaaj
Last active February 16, 2025 00:07
Show Gist options
  • Save ormaaj/b1a553673b7bf13b04c3bab9837f08d9 to your computer and use it in GitHub Desktop.
Save ormaaj/b1a553673b7bf13b04c3bab9837f08d9 to your computer and use it in GitHub Desktop.
field splitting
for sh in bash bb dash yash gash bosh ksh kshv mksh loksh posh zsh mrsh; do
printf '%-6s ' "${sh}:"
"$sh" -c 'IFS=0; bash -c "printf \"%q \" \"\$@\"" bash $((x=1101001101))$((x))$((IFS=!IFS))${x}$((x)) ${x}$((x)) "${y:=$((x))}"${y+${z=$((y))}"$((y))"${z}$((IFS=!IFS))}' 2>&3
echo
done 3>/dev/null
bash: '' '' 0 00 '' 0 '' '' 0 00 '' 0 '' '' '' 0 00 '' 0 '' '' 0 00 '' 0 '' '' 0 00 '' 0 '' '' 0 00 '' 0 110100110111 1 '' 11 1110100110111 1 '' 11 1
bb: '' '' 0 00 '' 0 '' '' 0 00 '' 0 '' '' '' 0 00 '' 0 '' '' 0 00 '' 0 '' '' 0 00 '' 0 '' '' 0 00 '' 0 110100110111 1 '' 11 1110100110111 1 '' 11 1
dash: '' '' 0 00 '' 0 '' '' 0 00 '' 0 '' '' '' 0 00 '' 0 '' '' 0 00 '' 0 '' '' 0 00 '' 0 '' '' 0 00 '' 0 110100110111 1 '' 11 1110100110111 1 '' 11 1
yash: '' '' 0 00 '' 0 '' '' 0 00 '' 0 '' '' '' 0 00 '' 0 '' '' 0 00 '' 0 '' '' 0 00 '' 0 '' '' 0 00 '' 0 110100110111 1 '' 11 1110100110111 1 '' 11 1
gash: '' '' 0 00 '' 0 '' '' 0 00 '' 0 '' '' '' 0 00 '' 0 '' '' 0 00 '' 0 '' '' 0 00 '' 0 '' '' 0 00 '' 0 110100110111 1 '' 11 1110100110111 1 '' 11 1
bosh: '' '' 0 00 '' 0 '' '' 0 00 '' 0 '' '' '' 0 00 '' 0 '' '' 0 00 '' 0 '' '' 0 00 '' 0 '' '' 0 00 '' 0 11 1 '' 11 111 1 '' 11 111 1 '' 11 111 1 '' 11 1
ksh: 11 1 '' 11 111 1 '' 11 1111 1 '' 11 111 1 '' 11 1 '' '' 0 00 '' 0 '' '' 0 00 '' 0 1101001101 '' 0 00 '' 0 1101001101 '' 0 00 '' 0 0
kshv: 11 1 '' 11 111 1 '' 11 1 '' '' 0 00 '' 0 '' '' 0 00 '' 0 '' '' 0 00 '' 0 '' '' 0 00 '' 0 1101001101 '' 0 00 '' 0 1101001101 '' 0 00 '' 0 '' ''
mksh: 11 1 '' 11 111 1 '' 11 1 '' '' 0 00 '' 0 '' '' 0 00 '' 0 '' '' 0 00 '' 0 '' '' 0 00 '' 0 1101001101 '' 0 00 '' 0 1101001101 '' 0 00 '' 0 ''
loksh: 110100110111010011011 '' '' 0 00 '' 0 1101001101 '' '' 0 00 '' 0 1101001101 1101001101 '' '' 0 00 '' 0 1101001101 '' '' 0 00 '' 0 0
posh: 110100110111010011011 '' '' 0 00 '' 0 1101001101 '' '' 0 00 '' 0 1101001101 1101001101 '' '' 0 00 '' 0 1101001101 '' '' 0 00 '' 0 0
zsh: 110100110111010011011 '' 0 00 '' 0 1101001101 '' '' 0 00 '' 0 1101001101 1101001101 '' 0 00 '' 0 1101001101 '' 0 00 '' 0 0
mrsh: '' 0 00 0 '' 0 00 0 '' '' 0 00 0 '' 0 00 0 '' 0 00 0 '' 0 00 0 110100110111 1 11 1110100110111 1 11 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment