Subject: parted -s emits a warning when shrinking a partition

From: Sean Warner <[email-masked]>
Date: Wed, 26 Jun 2024 23:51:38 +0100

I am also having this bug reported in 2017:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=879555

$ parted -v
parted (GNU parted) 3.6
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+
Written by
<http://git.debian.org/?p=parted/parted.git;a=blob_plain;f=AUTHORS>.

$ cat /etc/lsb-release 
DISTRIB_ID="ManjaroLinux"
DISTRIB_RELEASE="24.0.2"
DISTRIB_CODENAME="Wynsdey"

-- If increasing the size of a partition the following command works
but if shrinking a partition it gives a warning "Warning: Shrinking a
partition can cause data loss, are you sure you want to continue?" and
the command just exits back to the command prompt and no changes are
made to the partition.

sudo parted -s /dev/loop0 resizepart 1 46280703s

I assumed that parted -s would automatically supply a default value of
'Yes' in this instance?

According to the Parted Man page:
-s, --script
never prompts for user intervention

Is this a bug or am I misunderstanding something?

>From researching the interweb this might be a bug that for many years
has never been addressed.

Previous parted versions apparently allowed for something like:

sudo parted -s /dev/loop0 resizepart 1 yes 46280703s
or
sudo parted -s /dev/loop0 resizepart 1 46280703s yes

But in parted 3.6 there appears to be no way to make this work with
parted -s. The only option is to resort to the undocumented ---pretend-
input-tty <-- But is this safe to keep using if not documented? Any
plans to make ---pretend-input-tty an official "thing" in Parted?

Example that will work whether increasing or reducing the partition
size:

echo -e "resizepart 1 46280703s\nyes\nunit s\nprint\nquit" | sudo
parted /dev/loop0 ---pretend-input-tty

Any help much appreciated,

Flex