Change 'take' prompt and strip whitespace from input

This commit is contained in:
RevBar 2011-06-10 01:31:46 +02:00
parent 35100c59ef
commit 478c93cbeb

11
revbank
View file

@ -78,12 +78,10 @@ sub prompt {
print "\e[0m";
defined $input or return;
# Clean up backspaces... TODO: fix terminal :)
$input =~ s/^\cH+//;
$input =~ s/.\cH// while $input =~ /.\cH/;
$input =~ s/^\cH+//;
$input =~ s/^\s+//; # trim leading whitespace
$input =~ s/\s+$//; # trim trailing whitespace
if ($input =~ /^\s*abort\s*$/i) {
if ($input =~ /^abort$/i) {
print "$at\n";
next LINE; # Whoa, scary out-of-scope jump! But it works :)
}
@ -355,7 +353,8 @@ sub take {
while (not @users or not defined $amount) {
PROMPT: for (;;) {
my $input = prompt(
"User to take from, or total amount to finish: ",
"User to take from"
. (@users ? ", or total amount to finish: " : ": "),
[ users() ]
);
if ($p = parse_user($input)) {