summaryrefslogtreecommitdiff
path: root/parted
diff options
context:
space:
mode:
authorArvin Schnell <aschnell@suse.com>2021-08-13 13:02:27 +0000
committerBrian C. Lane <bcl@redhat.com>2021-08-25 15:29:38 -0700
commit72faef8673b5b1d00059608f0729e93cb21a7664 (patch)
tree7ac25b2172018d785f40fb6814f16e974e90632a /parted
parent74636ce7f34081e92c5680f34588217978306488 (diff)
downloadparted-72faef8673b5b1d00059608f0729e93cb21a7664.tar.gz
parted: Allow empty string for partition name
This makes it possible to pass an empty string in script mode e.g. to set no partition name (on GPT): parted -s ./disk.img mklabel gpt mkpart '""' ext2 1 100M Includes a new test for this feature. Signed-off-by: Brian C. Lane <bcl@redhat.com>
Diffstat (limited to 'parted')
-rw-r--r--parted/ui.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/parted/ui.c b/parted/ui.c
index b5948d3..25ad4f1 100644
--- a/parted/ui.c
+++ b/parted/ui.c
@@ -16,7 +16,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <config.h>
#include <config.h>
@@ -727,6 +726,7 @@ void
command_line_push_line (const char* line, int multi_word)
{
int quoted = 0;
+ int quotes_empty = 0;
char quote_char = 0;
char this_word [256];
int i;
@@ -754,6 +754,9 @@ command_line_push_line (const char* line, int multi_word)
if (quoted && *line == quote_char) {
quoted = 0;
+ /* allow empty partition name in script mode */
+ if (!i)
+ quotes_empty = 1;
continue;
}
@@ -761,9 +764,11 @@ command_line_push_line (const char* line, int multi_word)
if (quoted && line[0] == '\\' && line[1])
line++;
+ quotes_empty = 0;
this_word [i++] = *line;
}
- if (i || !multi_word) {
+ if (i || !multi_word || quotes_empty) {
+ quotes_empty = 0;
this_word [i] = 0;
command_line_push_word (this_word);
}