On Mon, Feb 24, 2025 at 4:14 PM Chet Ramey <chet.ra...@case.edu> wrote:
> > > > > The beast of burden is already done in bash, it does scan the fmt string > > recognise integer conversion specifier fetch the arg 'string' and apply > an > > integer validity test on it, this is on this last operation that the > > validity check could be replaced by a airth_eval(string) > > Sure, I get how it could be done. I just don't buy the argument for doing > it. > > .... > > Oh, it certainly could. I just don't think it adds anything. I know ksh93 > does it, but ksh93 threw arithmetic evaluation in a bunch of different > places before $((...)) came along, and I think arithmetic expansion renders > them superfluous. > Well I can provide a reason that pushed me toward arith exp for numeric conversion char in printf, but again I have no problem with bash not doing it, this is mainly to reduce my interactive work keyboard typing experience, i.e avoid to constantly type $((...) on each printf I type hundred of time a day. So bash can be used as a scripting language, and 'may be' verbose keyboard typing is acceptable with a lot a $((...)) everywhere in a script, but when doing interactive work saving this keyboard typing of $((...)) is a big deal, specially that my typing skills are below the average, and dislexie add to the complexity I keep doing $(...) in lieux of $((...)) with indeed and great usage of the history to fix the typo, thanx for that :-) In some aspect, the fmt reuse make a kind of iterator to produce thing while printf was not an iterator in spirit, we have of other iterator like {x..y} etc, the ftm reuse allow printf to become an iterator to prepend/append things to a word in wordlist, I abuse it a lot, on the same vein, I think the eval of num conversion is a kind of shortcut, and I love shortcut when I am typing :-) And indeed, printf could have a flag allowing num expression for num conversion, either printf option or shopt option, after all we do have option for extglob, meaning we deal with various form of patterns No need to say my .rc file have extglob on all the time and would have printf_numexpr on all the time too :-)