From 613ac9486be74143baf0cbfa1b19728b57ac463c Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Wed, 3 Aug 2016 11:09:45 +0200 Subject: [PATCH] don't save password and double lines in pvesh history we assumed that Term::ReadLine does not put input into the history automatically, but it does this so if this feature is enabled, we do not have to add the inputs manually, and we have to delete the password from the history Signed-off-by: Dominik Csapak --- bin/pvesh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/bin/pvesh b/bin/pvesh index ac704721..c5debe69 100755 --- a/bin/pvesh +++ b/bin/pvesh @@ -189,6 +189,14 @@ my $read_password = sub { my $input = $term->readline('password: '); my $conf = $term->readline('Retype new password: '); $attribs->{redisplay_function} = $old; + + # remove password from history + if ($term->Features->{autohistory}) { + my $historyPosition = $term->where_history(); + $term->remove_history($historyPosition); + $term->remove_history($historyPosition - 1); + } + die "Passwords do not match.\n" if ($input ne $conf); return $input; }; @@ -558,7 +566,11 @@ while (defined ($input = $term->readline("pve:/$cdir> "))) { exit (0); } - $term->addhistory($input); + # add input to history if it gets not + # automatically added + if (!$term->Features->{autohistory}) { + $term->addhistory($input); + } eval { my $args = [ shellwords($input) ]; -- 2.39.2