Bug#1039533: Offer a way to just print the numbers, not also the units
I added an example to the --terse entry in the manual. Debian should close this bug. On Thu, Jun 29, 2023 at 07:55:59AM -0500, Dan Jacobson wrote: > Ah ha! > You see the batch job user scours the man page, and only finds: > > >-1, --one-line > Give only one line of output (the forward conversion); do not > print the reverse conversion. If a reciprocal conversion is > performed, then units will still print the “reciprocal conver‐ > sion” line. > >-t, --terse > Print only a single conversion factor. This option can be used > when calling units from another program so that the output is > easy to parse. This option has the combined effect of these op‐ > tions: ‘--strict’ ‘--quiet’ ‘--one-line’ ‘--compact’. When > combined with ‘--version’ it produces a display showing only the > program name and version number. > >--compact > Give compact output featuring only the conversion factor; the > multiplication and division signs are not shown, and there is no > leading whitespace. If you convert to a unit list, then the > output is a semicolon separated list of factors. This turns off > the ‘--verbose’ option. > > But in fact, --terse should say: > >-t, --terse > Print only a single conversion factor. This option can be used > when calling units from another program so that the output is > easy to parse. This option has the combined effect of these op‐ > tions: ‘--strict’ ‘--quiet’ ‘--one-line’ ‘--compact’. When > combined with ‘--version’ it produces a display showing only the > program name and version number. And here we even strip > the units off: > > $ units --terse mile meters > 1609.344 > > I am saying that people who are looking to strip things down... their > eyes will focus on that part of the man page, so be sure to repeat that > feature there. > > So indeed, there is no need for things like, > > $ dlocate --help > -f, --filename-only Strip 'package: ' prefix from search output > -p, --package-only Output package names only when searching > > because units already has what it needs. It just needs to mention it on > the right spot on the man page again. Thanks.
Bug#1039533: Offer a way to just print the numbers, not also the units
> But in fact, --terse should say: > >-t, --terse > Print only a single conversion factor. This option can be used > when calling units from another program so that the output is > easy to parse. This option has the combined effect of these op‐ > tions: ‘--strict’ ‘--quiet’ ‘--one-line’ ‘--compact’. When > combined with ‘--version’ it produces a display showing only the > program name and version number. And here we even strip > the units off: > > $ units --terse mile meters > 1609.344 I think you're not fully understanding what's going on. There is no unit to "strip off". If you don't use --terse, this is what happens: adrian> units mile meters * 1609.344 / 0.00062137119 Note that no unit appears. You get the other clutter, but no units, because conversions DO NOT HAVE UNITS. Definitions have units. You were trying to use a definition when you should have been using a conversion. In any case some additional explanation and examples won't hurt, so I'll try to elaborate on this in the manual. For definitions, actually, the output can be even more cluttered: adrian> units --terse mile 5280 ft = 1609.344 m
Bug#1039533: Offer a way to just print the numbers, not also the units
Ah ha! You see the batch job user scours the man page, and only finds: -1, --one-line Give only one line of output (the forward conversion); do not print the reverse conversion. If a reciprocal conversion is performed, then units will still print the “reciprocal conver‐ sion” line. -t, --terse Print only a single conversion factor. This option can be used when calling units from another program so that the output is easy to parse. This option has the combined effect of these op‐ tions: ‘--strict’ ‘--quiet’ ‘--one-line’ ‘--compact’. When combined with ‘--version’ it produces a display showing only the program name and version number. --compact Give compact output featuring only the conversion factor; the multiplication and division signs are not shown, and there is no leading whitespace. If you convert to a unit list, then the output is a semicolon separated list of factors. This turns off the ‘--verbose’ option. But in fact, --terse should say: -t, --terse Print only a single conversion factor. This option can be used when calling units from another program so that the output is easy to parse. This option has the combined effect of these op‐ tions: ‘--strict’ ‘--quiet’ ‘--one-line’ ‘--compact’. When combined with ‘--version’ it produces a display showing only the program name and version number. And here we even strip the units off: $ units --terse mile meters 1609.344 I am saying that people who are looking to strip things down... their eyes will focus on that part of the man page, so be sure to repeat that feature there. So indeed, there is no need for things like, $ dlocate --help -f, --filename-only Strip 'package: ' prefix from search output -p, --package-only Output package names only when searching because units already has what it needs. It just needs to mention it on the right spot on the man page again. Thanks.
Bug#1039533: Offer a way to just print the numbers, not also the units
On Wed, Jun 28, 2023 at 04:41:46AM -0500, Dan Jacobson wrote: > Here we see the "d" items are mixed with the "m" items, > but the "m" isn't shown: > set 42.1527288 -87.8284360 42.1817060 -87.8275970 > geod +ellps=GRS80 -I < $@ > EOF > 1d14'1.178" -178d45'56.794" 3219.433 > > But you are right, > $ set $(units --terse 1mi) > $ echo $1 > 1609.344 > Me throwing away $2 without double checking it is really "m" will come > back to bite me one day. > > Anyway my only goal was to reduce needing a post processing method to edit > the result. (And thus needing different methods on differing operating > systems.) I'm confused about how the existing capability does not fully meet your needs. You TELL UNITS what you need and it won't give you any units on the output. This avoids the possibility of being bitten by assumptions later on, and no post processing is required. > > I was just hoping there was a way to say > units --give-me-just-how-many-meters(feet, etc.)-please This feature already exists. It's unit conversion. You just need to give the "I want" factor in your invocation, as I have noted in my earlier messages: units --terse mile meters The output is a bare number. Or, you know units --terse mile inch would display a bare number giving the mile in inches.
Bug#1039533: Offer a way to just print the numbers, not also the units
Here we see the "d" items are mixed with the "m" items, but the "m" isn't shown: set 42.1527288 -87.8284360 42.1817060 -87.8275970 geod +ellps=GRS80 -I <
Bug#1039533: Offer a way to just print the numbers, not also the units
On Tue, Jun 27, 2023 at 04:24:08AM -0500, Dan Jacobson wrote: > I am just saying that some commands, > like > > set 42.1527288 -87.8284360 42.1817060 -87.8275970 > geod +ellps=GRS80 -a -p -f %.6f -F %.4f -I +units=us-ft < $@ > EOF > 42.152729 -87.828436 42.181706 -87.827597 1.233661 181.234224 10562.4246 > > never give the units, > and some like units, always give the units... > OK I guess both need postprocessing. I don't really understand what you're saying here. The command you show is requesting output in feet, so the units have been specified. You do that in units by converting to the desired units, that is units --terse 1mi feet This seems to function precisely the same as geod. When you don't supply a "you want" conversion factor, units instead prints the definition reduced to primitive units. Without the attached units, this output is *not* meaningful. Suppose you wrote a script that invoked units under the assumption that "m" was the primitive unit but the user has done export UNITS_SYSTEM=gauss Then the output of definitions is in cm instead of meters, so your proposed unitless definition output would give a mile as "160934.4". But I guess that's better (?) than a user who defaulted to planck units, where you'd get 9.9e37 back as the definition of the mile. There is no fixed default for what the primitive units are, so you can't make assumptions.
Bug#1039533: Offer a way to just print the numbers, not also the units
I am just saying that some commands, like set 42.1527288 -87.8284360 42.1817060 -87.8275970 geod +ellps=GRS80 -a -p -f %.6f -F %.4f -I +units=us-ft <
Bug#1039533: Offer a way to just print the numbers, not also the units
The proposed option gives invalid/incorrect results. The value of 1 mile is not in fact 1609.334---the "m" is an essential part of the result. If you want the bare number you can do factor=$(units --terse 1mi m) If you don't know what the unit to convert to is---"m" in this case---then you don't know what the answer means, so you shouldn't be trying to do anything with it. So we will not add this feature. On Mon, Jun 26, 2023 at 06:42:17PM -0400, Dan Jacobson wrote: > Package: units > Version: 2.22-2 > Severity: wishlist > X-Debbugs-CC: adri...@gnu.org > > > Offer a way to just print the numbers, not also the units. > > Currently one must do: > set $(units --terse 1mi) > echo $1 > 1609.344 > > So maybe have a units --just-the-numbers, when combined with --terse, > would print just the 1609.344, not the "m".
Bug#1039533: Offer a way to just print the numbers, not also the units
Package: units Version: 2.22-2 Severity: wishlist X-Debbugs-CC: adri...@gnu.org Offer a way to just print the numbers, not also the units. Currently one must do: set $(units --terse 1mi) echo $1 1609.344 So maybe have a units --just-the-numbers, when combined with --terse, would print just the 1609.344, not the "m".