bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: printf - strange behaviour in debug mode (BASH_VERSION="5.2.21(1)-re


From: Greg Wooledge
Subject: Re: printf - strange behaviour in debug mode (BASH_VERSION="5.2.21(1)-release")
Date: Thu, 8 Feb 2024 12:42:56 -0500

On Thu, Feb 08, 2024 at 05:48:18PM +0200, Timotei Campian wrote:
> The culprit function is *printargs() { printf "%s|" "$@"; echo; }*
> 
> calling it with no arguments it prints as expected the pipe: "|"
> while in debug mode (set -x), only a *blank line* is printed:
> 
> $ printargs
> printargs
> + printargs
> + printf %sx
> x+ echo
> 
> $

It looks like your session used a different definition of printargs,
which has printf "%sx" instead of printf "%s|".

Here's what I get with the correct function:

unicorn:~$ bash-5.2
unicorn:~$ printargs() { printf "%s|" "$@"; echo; }
unicorn:~$ set -x
unicorn:~$ printargs
+ printargs
+ printf '%s|'
|+ echo

unicorn:~$ 

This one has the pipeline where yours has the x, in both places.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]