GNU bug report logs - #39135
Globbing with numbers does not allow me to specify order

Previous Next

Package: coreutils;

Reported by: Antti Savolainen <antti.savo <at> gmail.com>

Date: Tue, 14 Jan 2020 15:30:02 UTC

Severity: normal

Tags: notabug

Done: Bernhard Voelker <mail <at> bernhard-voelker.de>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 39135 in the body.
You can then email your comments to 39135 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#39135; Package coreutils. (Tue, 14 Jan 2020 15:30:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Antti Savolainen <antti.savo <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Tue, 14 Jan 2020 15:30:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Antti Savolainen <antti.savo <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: Globbing with numbers does not allow me to specify order
Date: Tue, 14 Jan 2020 10:44:21 +0200
[Message part 1 (text/plain, inline)]
When doing a shortcut to unmount in a specific order, I am unable to
specify order with angle brackets. For example using 'umount /dev/sda[132]'
will result in the system unmounting them in numerological order. First 1
then 2 and finally 3. What I need it to do is to first unmount 1, then 3
and finally 2. It would be nice for the glob to respect the order of
numbers that it was given.
[Message part 2 (text/html, inline)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#39135; Package coreutils. (Tue, 14 Jan 2020 21:24:02 GMT) Full text and rfc822 format available.

Message #8 received at 39135 <at> debbugs.gnu.org (full text, mbox):

From: Bernhard Voelker <mail <at> bernhard-voelker.de>
To: Antti Savolainen <antti.savo <at> gmail.com>, 39135 <at> debbugs.gnu.org
Subject: Re: bug#39135: Globbing with numbers does not allow me to specify
 order
Date: Tue, 14 Jan 2020 22:23:14 +0100
tag 39135 notabug
close 39135
stop

On 2020-01-14 09:44, Antti Savolainen wrote:
> When doing a shortcut to unmount in a specific order, I am unable to
> specify order with angle brackets. For example using 'umount /dev/sda[132]'
> will result in the system unmounting them in numerological order. First 1
> then 2 and finally 3. What I need it to do is to first unmount 1, then 3
> and finally 2. It would be nice for the glob to respect the order of
> numbers that it was given.

Thanks for the report, but you reached the GNU coreutils mailing list
while umount is part of util-linux, and the globbing you're referring to
is done by your shell.

Therefore, you're better off asking at the mailing lists of those packages.
As this is not a bug in coreutils, I'm marking it as such, and close this
issue in our bug tracker.

A little hint:
if your shell knows brace expansion "{...}", then you could use that
instead of file globbing with "[...]".  The following does this with
'echo' put in front of the command in order to see what would be
executed:

  $ echo umount /dev/sda{1,3,2}
  umount /dev/sda1 /dev/sda3 /dev/sda2

Have a nice day,
Berny




Added tag(s) notabug. Request was from Bernhard Voelker <mail <at> bernhard-voelker.de> to control <at> debbugs.gnu.org. (Tue, 14 Jan 2020 21:24:03 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 39135 <at> debbugs.gnu.org and Antti Savolainen <antti.savo <at> gmail.com> Request was from Bernhard Voelker <mail <at> bernhard-voelker.de> to control <at> debbugs.gnu.org. (Tue, 14 Jan 2020 21:24:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-coreutils <at> gnu.org:
bug#39135; Package coreutils. (Wed, 22 Jan 2020 17:26:02 GMT) Full text and rfc822 format available.

Message #15 received at 39135 <at> debbugs.gnu.org (full text, mbox):

From: Bob Proulx <bob <at> proulx.com>
To: Antti Savolainen <antti.savo <at> gmail.com>
Cc: 39135 <at> debbugs.gnu.org
Subject: Re: bug#39135: Globbing with numbers does not allow me to specify
 order
Date: Wed, 22 Jan 2020 10:25:39 -0700
Antti Savolainen wrote:
> When doing a shortcut to unmount in a specific order, I am unable to
> specify order with angle brackets. For example using 'umount /dev/sda[132]'
> will result in the system unmounting them in numerological order. First 1
> then 2 and finally 3. What I need it to do is to first unmount 1, then 3
> and finally 2. It would be nice for the glob to respect the order of
> numbers that it was given.

As Bernhard wrote this involves features that have nothing to do with
coreutils.  However I thought I might say some more too.

You say you would like character class expansion of file globbing to
preserve the order.  But that isn't something that it has ever done
before all of the way back 40 years.  The [...] brackets give the file
glob parser (its called glob because wildcards can match a glob of
files) a list of characters to match.  These can be ranges such as A-Z
or 0-9 and so forth.  The collection effectively makes a set of
characters.  This is expanded by the command line shell.  To see the
expansion one can use the echo command to echo them out.  Try this to
see what a command like yours is doing.

  echo /dev/sda[132]

That shows what the umount command line arguments are going to be.
The command line shell expands the wildcards and then passes the
resulting expansion to the command.  The command never sees the wild
card itself.

Therefore your specific desire is that the command line shell would do
something different from what it is doing now.  And that would be
something different from what it has ever done in the past.  This
would be a new behavior and a change in historic behavior.  And almost
certainly one that would break someone who is now depending upon the
current behavior of sorting the arguments.  They would then file a bug
that the arguments were no longer being sorted.  And they were there
first by decades.  Therefore if I were maintaining a shell I would not
want to make changes to that ordering since it would certainly break
others and generate more bug reports.

Instead if you need to have things happen in a specific order then the
task is up to you to specify an explicit order.  Bernhard suggested
brace expansion, which is a GNU bash specific feature.

  echo /dev/sda{1,3,2}
  /dev/sda1 /dev/sda3 /dev/sda2

However I am not personally a fan of bash-isms in scripts.  They won't
work everywhere.  Therefore I personally would just explicitly specify
the order.

  umount /dev/sda1
  umount /dev/sda3
  umount /dev/sda2

Doing things that way is unambiguous.  And if that is the correct
order then it is the correct order.

If you need a command line short cut to make typing this in easier
then I personally would create a small shell script.

  #!/bin/sh
  # Unmount the devices in mount dependency order.
  umount /dev/sda1
  umount /dev/sda3
  umount /dev/sda2

Store this in /usr/local/bin/umount-sda or some such name that makes
sense to you and chmod a+x the file to make it executable.  Then it is
a documentable command to do exactly what is needed.  Typical command
line completion with TAB will help as a typing aid to expand the file
name for you.  That is the way I would do it.

Bob




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 20 Feb 2020 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 66 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.