From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: Bug Report: glob qualifier Lm-1 does not work
Date: Sun, 05 Sep 2010 11:38:23 -0700 [thread overview]
Message-ID: <100905113823.ZM9231@torch.brasslantern.com> (raw)
In-Reply-To: <20100901180142.56a9180f@csr.com>
On Sep 1, 6:01pm, Peter Stephenson wrote:
} Subject: Re: Bug Report: glob qualifier Lm-1 does not work
}
} In other words, files "less than 1 megabyte" have to be zero. You'll see
} that it does indeed pick up files of zero size.
}
} The logic behind the reason is that this makes *(Lm-1), *(Lm1) and
} *(Lm+1) disjunct sets, as you might naively expect (until you worked
} out the implications) [...] although you might have thought it would
} make more sense to round file sizes down rather than up.
I seem to recall that these semantics are intended to produce the same
results as the output of "find" with the same -/+ modifiers. In my
zsh build tree,
find . -size 2k -print
print -l **/*(Lk2)
both ouptut the same 62 files, and with -2 both print the same 219
other files. If not for that, it might make the most sense to round
to the *nearest* size (or whatever measure) rather than up or down.
E.g. right now if U is a multiplier expressed in bytes for a unit such
as "megabyte" and S is a file size in bytes as read from stat(), zsh
computes
N = (S + (U - 1)) / U
using long integers so the result is truncated. Looking for files less
(or greater or equal) X units then compares N to X. But zsh could do
N = (S + (U / 2)) / U
and preserve the property of distinct sets while treating files less
than half a megabyte in size as "less than one" megabytes. However, I'm
not sure that would satisfy anyone either, because users couldd still
be confused as to why three-fourths of a megabyte is not less than one.
As I mentioned before, zsh instead could compare S to (X * U) without
rounding or truncating at all, which is probably what most people are
expecting; but then "files exactly 1 megabyte in size" becomes "too
precise."
Of course the ulitmate question here is, how does one express what
Roy actually intended when he wrote (Lm-1), other than by writing it
out longhand as (L-1048576)? (And is even that what was intended?)
I think the answer is that you can't. You must choose a multiplier
based on how precise a comparison you want.
prev parent reply other threads:[~2010-09-05 18:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-01 15:54 Roy Zuo
2010-09-01 16:16 ` Jérémie Roquet
2010-09-01 16:38 ` Roy Zuo
2010-09-01 16:36 ` Bart Schaefer
2010-09-01 17:01 ` Peter Stephenson
2010-09-05 18:38 ` Bart Schaefer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=100905113823.ZM9231@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).