Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The 'rename' command has multiple different versions #3125

Closed
principis opened this issue Jun 23, 2019 · 17 comments · Fixed by #3126
Closed

The 'rename' command has multiple different versions #3125

principis opened this issue Jun 23, 2019 · 17 comments · Fixed by #3126
Labels
bug Issues with our clients or rendering of pages, etc.

Comments

@principis
Copy link
Contributor

There are 2 versions of the rename command, a perl version for debian-based distros and the util-linux version which all other distros use. source
The page is written for the perl version.

This can cause problems (which it did for me because I'm using fedora) for users with the util-linux version because it doesn't use Perl expressions.
Perl: man-page
util-linux: man-page

I can't think of a solution for this problem... :/

@mebeim
Copy link
Member

mebeim commented Jun 23, 2019

Thank you for bringing this up, @principis.

I spent some time and did some research, and here's a summary of what I could find about the rename command. I'd like to emphasize that this is based on my two main systems, which are Debian and Ubuntu.

These are the three programs which are contenders for this page:

  • prename: this is a Perl script provided by the perl package (along with Perl itself). This script is no longer provided by the perl package on Ubuntu 17.10 and newer, but is still provided by the perl package for the latest LTS of Debian (Debian 9). I did not check whether or not it is still provided by perl on later Debian versions.

     SYNOPSIS from `man prename`:
     rename [ -v ] [ -n ] [ -f ] perlexpr [ files ]
    
  • file-rename: this is still a Perl script and is provided by the rename package. This is basically an updated version of prename. This can be installed either in Debian or Ubuntu and it is the same command on both distros.

     SYNOPSIS from `man file-rename`:
     rename [ -h|-m|-V ] [ -v ] [ -n ] [ -f ] [ -e|-E perlexpr]*|perlexpr [ files ]
    
  • rename.ul: this is a compiled C program provided by the util-linux package. This package has a Priority of Required, and therefore comes built-in in both Debian and Ubuntu.

     SYNOPSIS from `man rename.ul`:
     rename [options] expression replacement file...
    

So what's the deal? Which one is used and where?

  • The prename command is installed as an alternative[1] on Debian and Ubuntu <= 17.04. So basically this command is only still present in Debian.

  • The file-rename command is installed as an alternative on both Debian and Ubuntu.

  • The rename.ul[2] command is not installed as an alternative, and is therefore a standalone executable on both Debian and Ubuntu.

My suggestion

The TL;DR from what I explained above is that prename and file-rename are two alternatives for the rename command and are both Perl scripts, with file-rename being the more updated, and prename being seemingly deprecated on newer distros. The rename.ul command is a standalone command which does not seem to conflict with the other two.

Given these facts, I would suggest to:

  1. Check what's going on on other distributions and platforms. My analysis is only Debian and Ubuntu related.
  2. Move the rename.md page under Linux.
  3. Keep rename.md as is, and create a new rename.ul.md page.
  4. Last, but not least, and probably the most important point: add a line to the description of rename.md (and reaname.ul.md if created) specifying which command is exactly being described.

[1] Being installed as an alternative, for those who don't know, means that /usr/bin/rename is a symlink to /etc/alternatives/rename, and this second one is a symlink to whichever rename command is configured as default alternative (through the update-alternatives command).

[2] Note that rename.ul is the actual name of the command. That is, no rename command exists on Ubuntu 18 if you only have installed util-linux and not rename. I don't know if the .ul prefix was added or has been there since the beginning, but at least on my two machines using Ubuntu 18.04 (one AWS Micro instance and one personal laptop) it's like this.

@mebeim mebeim changed the title 'rename' command 2 versions The 'rename' command has two different versions Jun 23, 2019
@waldyrious
Copy link
Member

waldyrious commented Jun 23, 2019

As additional data, here's the information from Homebrew on macOS:

$ brew info rename
rename: stable 1.600 (bottled), HEAD
Perl-powered file rename script with many helpful built-ins
http://plasmasturm.org/code/rename
Conflicts with:
  util-linux (because both install `rename` binaries)
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/rename.rb

Is this consistent with your findings, @mebeim?

@mebeim
Copy link
Member

mebeim commented Jun 23, 2019

Update on other distributions and systems after some more digging:

  • CentOS 7, RHEL 8: the rename command is the C executable from util-linux, no prename or file-rename. No rename package is available through the yum package manager, and yum list all | grep rename yields nothing.

  • Fedora 30: the rename command is the C executable from util-linux, prename is available in the prename package.

  • openSUSE 15.1: the rename command is the C executable from util-linux. No rename package is available through the zypper package manager, zypper search rename lists H2rename, but that's an entirely different program.

  • MacOS (using Homebrew): rename is provided both by the util-linux and rename Homebrew packages. This means the two packages conflict. The rename pkg provides a Perl script, and the util-linux pkg provides a C compiled program. The Perl script however seems to differ from the Debian/Ubuntu file-rename and prename: it has more and maybe even different command line options (didn't check them by hand). A page should probably be created under the macos platform to avoid any problem. This should answer your question @waldyrious.

  • Windows 10: the rename command exists, but is entirely different in both purpose and syntax.

  • Solaris 11: as far as I could see, there's no rename command in Solaris. I cannot see one in the online documentation. I did not test this though, my Solaris VM isn't currently working.


So basically the main problem here is that on Linux, we have some distros which have a rename command which currently fits the existing rename.md page (Debian, Ubuntu), but also others which only have the different rename command from util-linux (CentOS, Fedora, RHEL, openSUSE).

I would still suggest what I said above. Moving rename.md under linux and adding a line to the description seems like the way to go to me.

@mebeim mebeim added the bug Issues with our clients or rendering of pages, etc. label Jun 23, 2019
@principis
Copy link
Contributor Author

principis commented Jun 23, 2019

Sounds good to me. Thanks for the research :)

I'll create a PR. Is this line fine? Or maybe too long?

> Keep in mind that this page concerns the perl version of rename, often known as `prename` or `file-rename`. See `rename.ul` for the util-linux version.

@sbrl
Copy link
Member

sbrl commented Jun 23, 2019

Wow, that's wildly complicated.

@principis: Sounds a bit on the wordy side. What about something like this?

> This is the perl version of `rename`, which is the default on Debian. See `rename.ul` for the stand-alone version.

@waldyrious
Copy link
Member

@mebeim just to make sure we all understand the status quo, would you mind compiling the information above into a table? Something like this (just a draft; incomplete and almost surely incorrect):

Perl
(vX)
Perl
(vY)
Perl
(vZ)
C Other
Linux (Debian) rename → prename file‑rename rename.ul
Linux (Ubuntu) rename → prename file‑rename rename.ul
Linux (CentOS, Fedora 30, RHEL 8) rename
Linux (OpenSuse)
macOS (Homebrew) rename rename
Windows rename

@mebeim
Copy link
Member

mebeim commented Jun 23, 2019

Sure @waldyrious, that's actually a pretty good idea. I also took a look at Arch Linux. Here's a table:

Perl (old) Perl (new) Perl (other?) C
Linux (Debian) prename (pkg perl), deprecated file‑rename (pkg rename) N/A rename.ul (pkg util-linux)
Linux (Ubuntu) N/A file‑rename (pkg rename) N/A rename.ul (pkg util-linux)
Linux (Arch) N/A N/A perl‑rename (pkg perl-rename) rename (pkg util-linux)
Linux (CentOS, RHEL) N/A N/A N/A rename (pkg util-linux)
Linux (Fedora) N/A N/A prename (pkg prename) rename (pkg util-linux)
Linux (openSUSE) N/A N/A N/A rename (pkg util-linux)
macOS (Homebrew) N/A N/A rename (pkg rename) rename (pkg util-linux)
Windows N/A N/A N/A N/A
Solaris N/A N/A N/A N/A

Oh boy, that's really a mess... 😥 I really don't get why Debian (or at least Ubuntu) didn't go with the util-linux command by default (or why they don't even offer it as an alternative).

Important notes:

  • On Windows, rename is a different command (therefore I did not list it above).
  • On Solaris, no rename command exists.
  • On macOS, Homebrew pakages rename and util-linux conflict.
  • On macOS, Homebrew package rename offers a Perl script that looks different from others.
  • On Arch Linux, package perl-rename offers a Perl script that also looks different from others.
  • On Feroda, package prename offers a Perl script that also looks different from others.
  • On Debian, prename and file-rename are alternatives for rename.
  • On Ubuntu, file-rename is the only alternative for rename.

@principis
Copy link
Contributor Author

principis commented Jun 24, 2019

@mebeim Debian was first with the perl command in 1999.... According to this post

On fedora prename is also available but not installed by default. It's this version.

@waldyrious
Copy link
Member

Jesus, what a mess indeed. Thanks so much for doing the table!

So after this, I suppose the next step is to create pages for the Windows and the macOS rename commands, just for completeness? Nice-to-haves would be the perl-rename, which is unique to Arch Linux, and prename assuming it's the same version in Debian and Fedora.

Also, what's up with the Arch and macOS/brew versions being different programs altogether? Is the original Perl rename not developed anymore? Would it make sense to suggest to both repositories to switch to the "standard" Perl rename implementation, to reduce user confusion?

@mebeim
Copy link
Member

mebeim commented Jun 24, 2019

@principis oh you're right there's the prename package... I don't know how I missed that. I updated my posts above. This is really wild.

@mebeim
Copy link
Member

mebeim commented Jun 24, 2019

So @waldyrious yes, first of all I would remove rename.md from common, and move it to linux. Then create two different pages for macOS and Windows. That's a start.

On Debian, prename says:

Deprecated program in use: rename as shipped with the Debian perl package will be removed after the release of stretch. Please install the separate 'rename' package which will provide the same command.

so that's out of the game I'd say.

As for the differences in all the Perl scripts, they really seem to be different, or at least they have different command line options. It's reeeeally confusing. I took a look at the authors for the ones I listed above, and they indeed are all different except macOS and Fedora (funny, huh).

  • Debian prename from pkg perl: Robin Barker & Larry Wall.
  • Debian/Ubuntu file-rename from pkg file-rename: Larry Wall.
  • Arch perl-rename from pkg perl-rename: Peder Stray (same as Fedora).
  • Fedora prename from pkg prename: Peder Stray (same as Arch).
  • macOS rename from pkg rename: Aristotle Pagaltzis.

The thing is that apparently a lot of people like to re-write their own version of rename inspired by the original Larry Wall's Perl example script.


I would suggest the following:

  • Have linux/rename.md with examples for the program in the util-linux pkg, which is the most commonly available and consistent tool, with the following warning in the description:

      > NOTE: this page refers to the command from the `util-linux` package.
      > For the Perl version, see `file-rename` or `perl-rename`.
    
  • Have linux/file-rename.md with examples for Debian and Ubuntu file-rename.

  • Have linux/perl-rename.md with examples for Arch's perl-rename, maybe with the following warning in the description:

      > NOTE: this page refers to the command provided by the `perl-rename` Arch Linux package.
    
  • Have macos/rename.md with examples for the program in the util-linux pkg (same reasoning as above), maybe with the following warning in the description:

      > NOTE: this page refers to the command from the `util-linux` Homebrew package.
    
  • Have windows/rename.md, with other examples since it's a different command.

@mebeim mebeim changed the title The 'rename' command has two different versions The 'rename' command has multiple different versions Jun 24, 2019
@principis
Copy link
Contributor Author

@mebeim the Peder Stray versions seems to be adapted from Larry Wall's script

AUTHOR
Peder Stray pederst@cpan.org, original script from Larry Wall.

What do we do with prename? symlink it to perl-rename? (it may break clients) or just leave it or copy it with a different description?

@mebeim
Copy link
Member

mebeim commented Jun 24, 2019

@principis yes, but the Peder Stray's one is still a very different script. As for prename that's a good question. I'm not really sure about using symlinks... @waldyrious what do you think?

@waldyrious
Copy link
Member

If we can use symlinks, and have them work properly (e.g. if when cloning the repo on linux, macos and windows) I'd say there's no downside to it. I'm not sure clients would have issues with them if they are properly replicated in the local filesystem.

In any case, the prename command is both old and not the default anywhere, so it's not a big deal if we don't have it covered, for the time being at least.

@principis
Copy link
Contributor Author

@waldyrious the fedora prename is the same as arch's perl-rename. (I forgot there is a Debian prename). This is terrible :o

@mebeim
Copy link
Member

mebeim commented Jun 24, 2019

Yep, that's the point @principis was making, he was talking about Fedora's prename, not Debian's prename. Do symlinks work fine cross platform and most importantly inside a ZIP archive? That was my main concern. Cloning is not the problem.

mebeim pushed a commit that referenced this issue Jul 18, 2019
Address the presence of multiple and different versions of the rename command
as discussed in issue #3125.

Changes made:

- Moved common/rename.md to linux/prename.md, documenting the Debian
  Perl rename command (which is deprecated).
- Created linux/file-rename.md for the Debian/Ubuntu `file-rename`.
- Created linux/perl-rename.md with examples for Arch Linux `perl-rename`.
- Created linux/rename.md for the `rename` command offered by the the
  `util-linux` package, the most common one and supported by the most
  platforms.
@sputnick-dev
Copy link
Contributor

Related There's also Python version :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues with our clients or rendering of pages, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants