Skip to main content
added 152 characters in body
Source Link
Petr Skocik
  • 29.6k
  • 18
  • 90
  • 154

You can output a character after the normal output and then strip it:

#capture the output of "$@" (arguments run as a command)
#into the exact_output` variable
exact_output() 
{
    exact_output=$( "$@" && printf X ) && 
    exact_output=${exact_output%X}
}

This is a POSIX compliant solution.

You can output a character after the normal output and then strip it:

#capture the output of "$@" (arguments run as a command)
#into the exact_output` variable
exact_output() 
{
    exact_output=$( "$@" && printf X ) && 
    exact_output=${exact_output%X}
}

You can output a character after the normal output and then strip it:

#capture the output of "$@" (arguments run as a command)
#into the exact_output` variable
exact_output() 
{
    exact_output=$( "$@" && printf X ) && 
    exact_output=${exact_output%X}
}

This is a POSIX compliant solution.

added 152 characters in body
Source Link
Petr Skocik
  • 29.6k
  • 18
  • 90
  • 154

You can output a character after the normal output and then strip it:

f#capture the output of "$@" (arguments run as a command)
#into the exact_output` variable
exact_output() 
{ 
 s=$   exact_output=$( "$@" && printf "%sX"X "$1"); s=${s%X};&& printf 
 "Captured: %q\n" "$s"; exact_output=${exact_output%X} 
}

You can output a character 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 after the normal output and then strip it:

#capture the output of "$@" (arguments run as a command)
#into the exact_output` variable
exact_output() 
{ 
    exact_output=$( "$@" && printf X ) &&  
    exact_output=${exact_output%X}
}
deleted 24 characters in body
Source Link
Petr Skocik
  • 29.6k
  • 18
  • 90
  • 154

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"; } 

You can output a character after the normal output and then strip it:

f(){ s=$(printf "%sX" "$1"); s=${s%X}; printf "Captured: %q\n" "$s"; } 
Source Link
Petr Skocik
  • 29.6k
  • 18
  • 90
  • 154
Loading