Change 'take' prompt and strip whitespace from input
This commit is contained in:
parent
35100c59ef
commit
478c93cbeb
1 changed files with 5 additions and 6 deletions
11
revbank
11
revbank
|
@ -78,12 +78,10 @@ sub prompt {
|
||||||
print "\e[0m";
|
print "\e[0m";
|
||||||
defined $input or return;
|
defined $input or return;
|
||||||
|
|
||||||
# Clean up backspaces... TODO: fix terminal :)
|
$input =~ s/^\s+//; # trim leading whitespace
|
||||||
$input =~ s/^\cH+//;
|
$input =~ s/\s+$//; # trim trailing whitespace
|
||||||
$input =~ s/.\cH// while $input =~ /.\cH/;
|
|
||||||
$input =~ s/^\cH+//;
|
|
||||||
|
|
||||||
if ($input =~ /^\s*abort\s*$/i) {
|
if ($input =~ /^abort$/i) {
|
||||||
print "$at\n";
|
print "$at\n";
|
||||||
next LINE; # Whoa, scary out-of-scope jump! But it works :)
|
next LINE; # Whoa, scary out-of-scope jump! But it works :)
|
||||||
}
|
}
|
||||||
|
@ -355,7 +353,8 @@ sub take {
|
||||||
while (not @users or not defined $amount) {
|
while (not @users or not defined $amount) {
|
||||||
PROMPT: for (;;) {
|
PROMPT: for (;;) {
|
||||||
my $input = prompt(
|
my $input = prompt(
|
||||||
"User to take from, or total amount to finish: ",
|
"User to take from"
|
||||||
|
. (@users ? ", or total amount to finish: " : ": "),
|
||||||
[ users() ]
|
[ users() ]
|
||||||
);
|
);
|
||||||
if ($p = parse_user($input)) {
|
if ($p = parse_user($input)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue