|
@ -43,11 +43,11 @@ int main(int argc, char** argv) { |
|
|
int distance = termux_levenshtein_distance(command_not_found, binary_name); |
|
|
int distance = termux_levenshtein_distance(command_not_found, binary_name); |
|
|
if (distance == 0 && strcmp(command_not_found, binary_name) == 0) { |
|
|
if (distance == 0 && strcmp(command_not_found, binary_name) == 0) { |
|
|
if (best_distance == 0) { |
|
|
if (best_distance == 0) { |
|
|
printf("or\n"); |
|
|
fprintf(stderr, "or\n"); |
|
|
} else { |
|
|
} else { |
|
|
printf("The program '%s' is not installed. Install it by executing:\n", binary_name); |
|
|
fprintf(stderr, "The program '%s' is not installed. Install it by executing:\n", binary_name); |
|
|
} |
|
|
} |
|
|
printf(" pkg install %s\n", current_package); |
|
|
fprintf(stderr, " pkg install %s\n", current_package); |
|
|
best_distance = 0; |
|
|
best_distance = 0; |
|
|
} else if (best_distance == distance) { |
|
|
} else if (best_distance == distance) { |
|
|
guesses_at_best_distance++; |
|
|
guesses_at_best_distance++; |
|
@ -65,12 +65,12 @@ int main(int argc, char** argv) { |
|
|
if (best_distance == 0) return 127; |
|
|
if (best_distance == 0) return 127; |
|
|
|
|
|
|
|
|
if (best_distance == -1 || best_distance > 3) { |
|
|
if (best_distance == -1 || best_distance > 3) { |
|
|
printf("%s: command not found\n", command_not_found); |
|
|
fprintf(stderr, "%s: command not found\n", command_not_found); |
|
|
} else { |
|
|
} else { |
|
|
printf("No command '%s' found, did you mean:\n", command_not_found); |
|
|
fprintf(stderr, "No command '%s' found, did you mean:\n", command_not_found); |
|
|
if (guesses_at_best_distance == 1) { |
|
|
if (guesses_at_best_distance == 1) { |
|
|
// Only one suggestion - show it:
|
|
|
// Only one suggestion - show it:
|
|
|
printf(" Command '%s' from package '%s'\n", best_command_guess, best_package_guess); |
|
|
fprintf(stderr, " Command '%s' from package '%s'\n", best_command_guess, best_package_guess); |
|
|
} else { |
|
|
} else { |
|
|
// Multiple suggestions at the same distance - show them all:
|
|
|
// Multiple suggestions at the same distance - show them all:
|
|
|
for (int i = 0; i < num_commands; i++) { |
|
|
for (int i = 0; i < num_commands; i++) { |
|
@ -79,7 +79,7 @@ int main(int argc, char** argv) { |
|
|
char const* binary_name = current_line + 1; |
|
|
char const* binary_name = current_line + 1; |
|
|
int distance = termux_levenshtein_distance(command_not_found, binary_name); |
|
|
int distance = termux_levenshtein_distance(command_not_found, binary_name); |
|
|
if (best_distance == distance) { |
|
|
if (best_distance == distance) { |
|
|
printf(" Command '%s' from package '%s'\n", binary_name, current_package); |
|
|
fprintf(stderr, " Command '%s' from package '%s'\n", binary_name, current_package); |
|
|
} |
|
|
} |
|
|
} else { // Package
|
|
|
} else { // Package
|
|
|
strncpy(current_package, current_line, sizeof(current_package)); |
|
|
strncpy(current_package, current_line, sizeof(current_package)); |
|
|