bug-bash
[Top][All Lists]
Advanced

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

Re: EPOCHREALTIME


From: Greg Wooledge
Subject: Re: EPOCHREALTIME
Date: Thu, 19 Aug 2021 12:42:04 -0400

On Thu, Aug 19, 2021 at 06:18:46PM +0200, Léa Gris wrote:
> printf arguments are program source even if argument comes from a variable.

I don't agree with this.  I'd say that the *first* argument of printf
is part of the program source code, and any additional arguments given
are typically data, but *could* be source code in special cases.

printf '%s\n' "$var"

The above is the typical use of printf.  The first argument is crafted
by the programmer, and the remaining argument(s) are data fed to the
printf command as input.

Below, a less common use of printf, where all but one of the additional
arguments should be considered source code:

printf '%s\n' H 1i "$1" . w | ed -s "$2"

This is taken from <https://wiki.bash-hackers.org/howto/edit-ed>.  The
argument in the middle, "$1", is clearly data.

> All things considered, if you are using floating-point numbers in a shell
> script, you are clearly not using the right tool for the job, but sometimes
> options are limited or not under your control.

Mostly true.  Using the shell's printf to round/format the display of a
floating-point number is acceptable, but it's right on the margin.

> Having a feature implemented in such a way, *that it cannot be used reliably
> or requires heavy work-around* (especially if you both need to process
> floating-point data in a portable format, and display in locale format)… is
> just calling for frustration and sorry errors:

You've just described almost every aspect of shell scripting.



reply via email to

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