All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masatake YAMATO <yamato@redhat.com>
To: kzak@redhat.com
Cc: util-linux@vger.kernel.org
Subject: Re: [PATCH 0/4] fincore command
Date: Wed, 15 Mar 2017 02:52:23 +0900 (JST)	[thread overview]
Message-ID: <20170315.025223.59681218388873786.yamato@redhat.com> (raw)
In-Reply-To: <20170313145041.senno5cucpkp6s57@ws.net.home>

Hi, thank you for comments.

On Mon, 13 Mar 2017 15:50:41 +0100, Karel Zak <kzak@redhat.com> wrote:
> Not sure if I like the format ;-)
> 
>  $ fincore /etc/fstab /bin/emacs
>  1          1544       /etc/fstab
>  4156       17163144   /bin/emacs
> 
> Why we need file size there? Would be better to use filename as the
> first column?

* Why we need file size there?

I don't insist including the file size column.

The original reason was that I assumed that a user may want to know
how much part of the file printed by fincore is in core. The file-size
column is for the hint.

How about adding an option to control show the column (--file-size|-s)?
Or should I delete the column fron the output completely?

* Would be better to use filename as the first column?

I follow the format that du and ls commands use:

    $ du /etc/passwd
    4	/etc/passwd

    $ ls -i /tmp | head
    67003 emacs1000
    47611 systemd-private-dd34e7d700c6441db79e4caa7b3c3205-colord.service-N7dhub
    24891 systemd-private-dd34e7d700c6441db79e4caa7b3c3205-rtkit-daemon.service-WbOmt1

du and ls are popular enough. So potential users of fincore
command may be familiar with the formats.

There are two benefits this(du style) format.

+ awk/read/cut commands friendly

White spaces can be included in a file name.
As the result, a user cannot assume the column
for the page counts easily if filename is at the
first column.

e.g. 

    (the format in my patch)
    $ touch 'a b'
    $ ./util-linux/fincore 'a b'
    0          0          a b
    $ ./util-linux/fincore 'a b' | awk '{print $1}'
    0
    $ ./util-linux/fincore 'a b' | { read A REST; echo $A; }
    0
    $ ./util-linux/fincore 'a b' | cut -d ' ' -f1 
    0

+ beauty of output

If filename is at the first column, I wonder
how can I print lines in column aligned way:

    0         -1         /foo/bar/baz/very---long---file---name
    0          0          shortname

By finding the longest file name from arguments passed to fincore
command, the column length can be calumniated, and fincore may be
able to print following lines:

    /foo/bar/baz/very---long---file---name	0         -1         
    shortname					0          0

However, I wonder what I should do if multibyte characters are
used in the file name.

Of course, the column alignment is less important than providing the
way to know much file contents are incore to users.

> it would be also nice have a way how to print only the number if only one
> file specified. Then you can use it in scripts without awk (or so),
> just:
> 
>   FILEPAGES=$(fincore /bin/emacs)
> 

In the station(interactive use) that a user of fincore knows the
number of file names passed to the command, printing only the number
is bettern. However, there can be a situation(scripting) that a user
cannot know the number of file names.

{ 
  FILES=...
  FILES="$FILES $tmp"
  ...
  
  fincore $FILES
} | do_something

In such case the columns are fixed(the page numbers and file name)
will be better for people writing `do_something'. For the such
use case, I would like to add an option --print-filename-always.
The default behavior (behavior without the option) should be
implemented as what you wrote (just printing the number).
Is it o.k.?

After getting feedback from you, I will submit v2 patches.

Masatake YAMATO

  reply	other threads:[~2017-03-14 17:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-07  2:33 [PATCH 0/4] fincore command Masatake YAMATO
2017-03-07  2:33 ` [PATCH 1/4] fincore: new command for counting pages of file contents in core Masatake YAMATO
2017-03-07  2:33 ` [PATCH 2/4] man: add a page for fincore command Masatake YAMATO
2017-03-07  2:33 ` [PATCH 3/4] tests: add cases for testing " Masatake YAMATO
2017-03-07  2:33 ` [PATCH 4/4] bash-completion: add a function for " Masatake YAMATO
2017-03-13 14:50 ` [PATCH 0/4] " Karel Zak
2017-03-14 17:52   ` Masatake YAMATO [this message]
2017-03-23 11:33     ` Karel Zak
2017-03-23 11:58 ` Karel Zak
2017-03-23 14:45   ` Karel Zak
2017-03-27  0:41     ` Masatake YAMATO
2017-03-27 11:09       ` Karel Zak

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=20170315.025223.59681218388873786.yamato@redhat.com \
    --to=yamato@redhat.com \
    --cc=kzak@redhat.com \
    --cc=util-linux@vger.kernel.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.