Lines 120-135
sub tell_bash_to_unhash_codespell {
Link Here
|
120 |
my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run( command => $cmd, verbose => 0 ); |
120 |
my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run( command => $cmd, verbose => 0 ); |
121 |
} |
121 |
} |
122 |
|
122 |
|
|
|
123 |
# returns 1 if Codespell should have -L after calling this. |
124 |
# returns 0 if it was not fixed. |
125 |
sub fix_if_desired { |
126 |
my $result = 0; |
127 |
print STDERR "Would you like to update Codespell? (y/N) "; |
128 |
my $answer = <STDIN>; |
129 |
if ($answer =~ /[yY]/ ) { |
130 |
remove_codespell; |
131 |
install_codespell; |
132 |
tell_bash_to_unhash_codespell; |
133 |
$result = 1; |
134 |
} |
135 |
return $result; |
136 |
} |
137 |
|
138 |
sub have_codespell { |
139 |
my $have_it = 0; |
140 |
if ( -f '/usr/bin/codespell' || -f '/usr/local/bin/codespell' ) { |
141 |
$have_it = 1; |
142 |
} |
143 |
return $have_it; |
144 |
} |
145 |
|
123 |
sub check_spelling { |
146 |
sub check_spelling { |
124 |
my ($self) = @_; |
147 |
my ($self) = @_; |
125 |
|
148 |
|
|
|
149 |
return 0 if ! have_codespell(); |
150 |
|
151 |
my $has_l_option = 1; |
126 |
if (! codespell_has_L_option()) { |
152 |
if (! codespell_has_L_option()) { |
127 |
print STDERR "\nCodespell missing required -L option!\n"; |
153 |
print STDERR "\nCodespell missing -L option!\n"; |
128 |
remove_codespell; |
154 |
$has_l_option = fix_if_desired; |
129 |
install_codespell; |
155 |
} |
130 |
tell_bash_to_unhash_codespell; |
156 |
my $cmd; |
|
|
157 |
if ($has_l_option) { |
158 |
$cmd = q{codespell -L sheat -d } . $self->path; |
159 |
} else { |
160 |
$cmd = q{codespell -d } . $self->path; |
131 |
} |
161 |
} |
132 |
my $cmd = q{codespell -L sheat -d } . $self->path; |
|
|
133 |
my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run( command => $cmd, verbose => 0 ); |
162 |
my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run( command => $cmd, verbose => 0 ); |
134 |
|
163 |
|
135 |
return 0 unless @$full_buf; |
164 |
return 0 unless @$full_buf; |