2

In pacman, --refresh and -y are the same option. But how are they phonetical related to each other? Is there a mnemonic?

For comparison: for many binaries -f is the short option of --force. It should be obvious how "f" is derived from "force" :)

muru
  • 72,889

1 Answers1

4

There are said to be two hard problems in computer science. One of those is naming things. This is an effect of that.

The database syncing feature was originally added as a separate pacsync command in 1.23. This command was then merged into pacman in the 2.0 release, and pacman gained many new options, including --sync/-S. Internally, this was still handled in a pacsync.c, and the action of refreshing the database was called syncing (the sync subcommand of the old pacsync, the sync_synctree() function in the new pacsync.c). Now we already have a master --sync option, so what do we do with the sub-option to that which syncs databases? I speculate that:

  • the devs decided to call it --refresh as a long option, a reasonable name,
  • but otherwise honour the sync-named things in the code by thinking of it as a second --sync option, because those things are sensibly named
  • and therefore, as is usually done when two long options have the same first character, moved to the second character for the short option, -y.

As a factor in favour of this, the combination would become -Sy, the first two letters of "sync'.

Part of the code for option handling:

while((opt = getopt_long(argc, argv, "ARUQSTYr:vhscVfnoldpiuy", opts, &option_index))) {
    if(opt < 0) {
        break;
    }
    switch(opt) {
...
        case 'y': pmo_s_sync = 1; break;

This whole thing happened ~15 years ago (2002), and I couldn't find any online discussions about in my searching, but I'm confident this is what happened.

muru
  • 72,889
  • Hi @muru, thank you for refining my question and giving a reasonable answer. I like the answer very much, especially because you gave me a mnemonic for -Sy(nc) – Thomas Steinbach Dec 16 '17 at 14:27