[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Does -s apply to -m in sort?
From: |
Eric Blake |
Subject: |
Re: Does -s apply to -m in sort? |
Date: |
Wed, 13 May 2020 17:03:16 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 |
On 5/11/20 5:01 PM, Eric Blake wrote:
You also didn't state whether you tried the --debug option, to see if
the presence or absence of -s showed enough debugging crumbs to prove
that you at least tried to analyze the problem yourself. Nor did you
mention whether you read the source code (it _is_ open source, after
all, so instead of asking someone else to do your homework, _you_ can
find the answer).
In an effort to teach you how to read source code, and looking at
coreutils.git commit c7194b43 (current master as I write this), look at
src/sort.c:
In function main(), there is a getopt_long() loop, where '-m' sets
'mergeonly = true' (line 4493), and '-s' sets 'stable = true' (line
4513). A quick grep shows that:
$ grep -C 10 '\bstable\b' src/sort.c | grep -c mergeonly
0
there are 0 instances of one variable referenced within ten lines of
locality to the other. So there are likely no explicit interlocking
between the two options (that is, turning on one doesn't affect the
other, they can both be turned on independently).
Next, try to see where things are used.
in main(), if mergeonly is set, we call merge() (line 4752)
in merge(), we unconditionally call mergefiles() (line 3816)
in mergefiles(), we unconditionally call mergefps() (line 3138)
in mergefps(), we unconditionally call compare() (line 2992)
in compare(), the code checks the value of 'stable' if there is a
keylist (line 2746)
So on that basis alone, yes, -s has effects when -m is used (but more
importantly, -s only matters when -k is used).
Now, please quit wasting time.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org