#977046 parted: support pattern matching, e.g. parted -s /dev/sd[b-c] "print"

Package:
parted
Source:
parted
Description:
disk partition manipulator
Submitter:
Date:
2020-12-12 16:24:03 UTC
Severity:
wishlist
Tags:
#977046#5
Date:
2020-12-10 15:51:39 UTC
From:
To:
Hello,

please consider to support pattern matching, e.g.
parted -s /dev/sd[b-c] "print"

Best regards,

Werner

- -- System Information:
Debian Release: 10.7
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.19.0-13-amd64 (SMP w/2 CPU cores)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8), LANGUAGE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages parted depends on:
ii  libc6         2.28-10
ii  libparted2    3.2-25
ii  libreadline7  7.0-5
ii  libtinfo6     6.1+20181013-2+deb10u2

parted recommends no packages.

Versions of packages parted suggests:
pn  parted-doc  <none>

- -- no debconf information
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEE5C+AKX3ilVyzT1u+Ib3VvhD/8swFAl/SRAIACgkQIb3VvhD/
8swNhxAAw1TPd/0Jx8cfy+569X6kr0jJtpbE8qR4AB3RK6jmLUGnks6K5Qko+n4f
1vLaZHfim4F8vmyaN3aaGe9TiW4COi2nZXmJPCngyRoFal2bCXZMEcPPDXLTyx90
UxPqPC1+OyPblDXMCi85CORC1yO3E0zC0M1HdbpRhVcZB920KZyxTw9JrW6ZG3dJ
XQkI46kDV9gIoHfmyxLdEKtUyUWcAssDuHNtTCpomAen60pH1fDO0RkQswiRlknB
WXsZBkKaiE79arT90MEUOcn6Hqb/19Kc1ppLakqcjq+VKINaB19mws0hpOAkAToI
b7sjsfRyGN5IKwcUE+XniI1qQKcvq1jTDL4sYYryDazQ0QKr7opN5psNYNmtA4Tm
t587t6PvVFotmaBCrTEKCcuO8e2PUUAp21/AyBwWVKhUQ1U0dHOEVDYclcSsDAOU
KcKfkUf2Rm3FlU5KP0wmidtRV8ySmlhxl5ncRaTWDpyv4VUWK1xPe8+XFUNjRK2O
F43z+n+ebydIAU9FZHl/Knqleh05y19cNmOMXvtazp4GIxnoCO7bKm+XM5qcA0/P
XxdrY7E1c/6ADb+tnx8DmnS9dHnJPuTSSbBGwzn60A7n+3PYJKvKkYHlDYTk7YOJ
qiK4iteUppaSBc8GxtA49YKG1Ht5FllsfyVAMqdaI+XHePEzRGg=
=Ag5o
-----END PGP SIGNATURE-----

#977046#10
Date:
2020-12-11 09:53:06 UTC
From:
To:
The problem with anything like this would be that the shell would expand
the pattern, so parted itself would see the argument list as:

  parted -s /dev/sdb /dev/sdc print

The only ways I can think of to solve this would be:

 * use a different pattern syntax that doesn't collide with shell
   metacharacters (unlikely to be a good idea)
 * require users to quote the pattern to protect it from shell expansion
   (clumsy)
 * allow -s to take multiple device arguments until they stop looking
   like valid devices

But I think this is special-purpose enough that it's unlikely to be
worth the effort to implement in parted, when you could just use a shell
loop instead (granted, it's longer, but it composes nicely and the
meaning is unambiguous):

  for dev in /dev/sd[b-c]; do parted -s "$dev" print; done

You're welcome to file your request directly upstream yourself, but
since I'm not convinced that it should be implemented given the
disadvantages, I don't currently plan to forward it.

Thanks,

#977046#15
Date:
2020-12-12 16:21:13 UTC
From:
To:
Hi Colin,

thank you for your fast and friendly answer. Yes, indeed
my suggestion is only small and it's easy to use
a loop instead, of course.

The idea came to me, when I used parted to
prepare some disks for RAID as well
as for LVM2. Both tools (e.g. mdadm, pvcreate) can
handle a list of devices out of the box. So I just
wondered why  parted (and sfdisk) don't.

Best regards,

Werner