Re: "printf %d ''" should diagnose the empty string

2025-02-13 Thread Phi Debian
On Thu, Feb 13, 2025 at 6:18 AM Oğuz  wrote:

>
>
> Changes made to built-in printf have to be adopted by GNU printf, otherwise
> the user will have two flavors of printf on the same system by the same
> name.
> --
> Oğuz
>

You sure about the adopted by GNU printf assertion ?

$ /usr/bin/printf '%(*)T\n'
/usr/bin/printf: %(: invalid conversion specification
$ printf '%(*)T\n'
*

It is clear the buitin printf != /bin/printf


Re: "printf %d ''" should diagnose the empty string

2025-02-13 Thread Greg Wooledge
On Thu, Feb 13, 2025 at 08:17:45 +0300, Oğuz wrote:
> Changes made to built-in printf have to be adopted by GNU printf, otherwise
> the user will have two flavors of printf on the same system by the same
> name.

On Debian 12, /bin/echo (which is from GNU coreutils) and bash's builtin
echo do not share the same feature set:

hobbit:~$ /bin/echo -e '\u0061'
\u0061
hobbit:~$ echo -e '\u0061'
a

As was pointed out earlier, builtin printf and /usr/bin/printf also
have different features (%(fmt)T being one of them).

Having two different printfs, and two or more different echos, has
ALWAYS been the case on non-GNU-based systems (commercial Unix, BSD,
etc.) where bash is being used.

If the world weren't so narrowly "Windows, Mac and Linux" nowadays,
perhaps people would remember the diversity of operating systems a
little better.



Re: "printf %d ''" should diagnose the empty string

2025-02-13 Thread Oğuz
On Thursday, February 13, 2025, Phi Debian  wrote:

> '%(*)T\n'
>

GNU date already provides that functionality and is shipped alongside GNU
printf. It wouldn't be possible to implement the special argument -2 to
`%(datefmt)T' in an external utility anyway.

And yes, I am sure; if built-in printf and GNU printf differ in common use
cases that's a clear bug from the user's perspective.


-- 
Oğuz


Re: "printf %d ''" should diagnose the empty string

2025-02-13 Thread Phi Debian
On Thu, Feb 13, 2025 at 10:27 AM Oğuz  wrote:

> And yes, I am sure; if built-in printf and GNU printf differ in common use
> cases that's a clear bug from the user's perspective.
>

There must be a bug somewhere then :-)

$ printf 1 2 3 4
1

$ /bin/printf 1 2 3 4
1/bin/printf: warning: ignoring excess arguments, starting with ‘2’

$ printf '1\n' 2
1
$ /bin/printf '1\n' 2
1
/bin/printf: warning: ignoring excess arguments, starting with ‘2’


As long as the 2 printf's are not from the same source, divergence is
always possible...


Re: [Suggestion] Add warning/error when using the tilde expansion in a folder where the tile-named file/folder exists

2025-02-13 Thread Chet Ramey

On 2/12/25 10:50 AM, Andrés Rodríguez Reina wrote:


Bash Version: 5.0
Patch Level: 17
Release Status: release

Description:
 Due to a mistake in coding a script, a folder named '~' was generated. An 
unexperienced bash user issued the command "rm -rf ~" by mistake, intending to 
delete the '~' folder, but this resulted in deleting 150GB+ of data at their home 
directory.



 In my opinion, it would be useful to have a warning be issued when in 
interactive mode, when at the current working directory a file/folder named '~' 
exists, and a command with a parameter starting with ~ is used (which will 
produce tilde expansion).


Thanks for the suggestion. I'm not inclined to implement it.

Chet


--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/


OpenPGP_signature.asc
Description: OpenPGP digital signature


Re: "printf %d ''" should diagnose the empty string

2025-02-13 Thread Chet Ramey

On 2/13/25 12:17 AM, Oğuz wrote:


Changes made to built-in printf have to be adopted by GNU printf, otherwise
the user will have two flavors of printf on the same system by the same
name. `-v varname' is irrelevant because it's obvious an external command
can't change the value of a shell variable.


There already are differences: bash has extensions and there are different
things that generate warnings. However, in this case, bash-5.3-beta and
coreutils printf both warn about an empty string argument.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/


OpenPGP_signature.asc
Description: OpenPGP digital signature