You can output a character that's not a whitespace after the normal output and then strip it:
f(){ s=$(printf "%sX" "$1"); s=${s%X}; printf "Captured: %q\n" "$s"; }
You can output a character that's not a whitespace after the normal output and then strip it:
f(){ s=$(printf "%sX" "$1"); s=${s%X}; printf "Captured: %q\n" "$s"; }