Skip to contentSkip to conversation

master - fix running commands from a script file

PATCH David Teigland 1 participant 1 message Apr 28, 2017

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=54726a4950756b8f0c3e19c4c7d5feb6fb838e00
Commit:        54726a4950756b8f0c3e19c4c7d5feb6fb838e00
Parent:        c73b9f062c8ed59dc0bfa859cab4a692295a56cb
Author:        David Teigland <[email protected]>
AuthorDate:    Fri Apr 28 16:43:42 2017 -0500
Committer:     David Teigland <[email protected]>
CommitterDate: Fri Apr 28 16:51:04 2017 -0500

fix running commands from a script file

Using any arg with a command name in a script file would cause the command to fail.

The name of the script file being executed was being passed to lvm_register_commands() and define_commands(), which prevented command defs from being defined (simple commands were still being defined only by name which was enough for those to still work when run trivially with no args).

---
 WHATS_NEW          |    1 +
 tools/lvmcmdline.c |    4 ++++
 2 files changed, 5 insertions(+), 0 deletions(-)
WHATS_NEW +1 -0
index 2db7dc4..846e998 100644
@@ -1,5 +1,6 @@
 Version 2.02.171 - 
 ==================================
+  Fix running commands from a script file.
   Add pvcreate prompt when device size doesn't match setphysicalvolumesize.
   lvconvert - preserve region size on raid1 image count changes
   Adjust pvresize/pvcreate messages and prompt if underlying dev size differs.
tools/lvmcmdline.c +4 -0
index c0c81ba..29ec06b 100644
@@ -3444,6 +3444,10 @@ int lvm2_main(int argc, char **argv)
 		goto_out;
 	}
 
+	/* Can be the name of a script file. */
+	if (run_name && !find_command_name(run_name))
+		run_name = NULL;
+
 	if (!lvm_register_commands(run_name)) {
 		ret = ECMD_FAILED;
 		goto out;