mirror of https://github.com/CrimsonTome/tldr.git
scripts/wrong-filename.sh: add ignore list + extra replacements (#12729)
parent
55ac5e27fe
commit
c8d6b81588
|
@ -1,4 +1,4 @@
|
||||||
# Tipo
|
# Type
|
||||||
|
|
||||||
> Muestra el tipo de comando que ejecutará el intérprete de comandos.
|
> Muestra el tipo de comando que ejecutará el intérprete de comandos.
|
||||||
> Nota: todos los ejemplos no son compatibles con POSIX.
|
> Nota: todos los ejemplos no son compatibles con POSIX.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Tanda seru
|
# Exclamation mark
|
||||||
|
|
||||||
> Digunakan pada Bash sebagai pengganti perintah yang sebelumnya dieksekusikan.
|
> Digunakan pada Bash sebagai pengganti perintah yang sebelumnya dieksekusikan.
|
||||||
> Informasi lebih lanjut: <https://www.gnu.org/software/bash/manual/bash.html#Event-Designators>.
|
> Informasi lebih lanjut: <https://www.gnu.org/software/bash/manual/bash.html#Event-Designators>.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/sh
|
#!/usr/bin/env bash
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
# This script checks consistency between the filenames and the page title.
|
# This script checks consistency between the filenames and the page title.
|
||||||
|
@ -9,18 +9,20 @@ OUTPUT_FILE="inconsistent-filenames.txt"
|
||||||
# Remove existing output file (if any)
|
# Remove existing output file (if any)
|
||||||
rm -f "$OUTPUT_FILE"
|
rm -f "$OUTPUT_FILE"
|
||||||
|
|
||||||
|
IGNORE_LIST=("exclamation mark" "caret")
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Iterate through all Markdown files in the 'pages' directories
|
# Iterate through all Markdown files in the 'pages' directories
|
||||||
find pages* -name '*.md' -type f | while read -r path; do
|
find pages* -name '*.md' -type f | while read -r path; do
|
||||||
# Extract the expected command name from the filename
|
# Extract the expected command name from the filename
|
||||||
COMMAND_NAME_FILE=$(basename "$path" | head -c-4 | tr '-' ' ' | tr '[:upper:]' '[:lower:]')
|
COMMAND_NAME_FILE=$(basename "$path" | head -c-4 | sed 's/nix3/nix/' | sed 's/\.fish//' | sed 's/\.js//' | sed 's/\.1//' | tr '-' ' ' | tr '[:upper:]' '[:lower:]')
|
||||||
|
|
||||||
# Extract the command name from the first line of the Markdown file
|
# Extract the command name from the first line of the Markdown file
|
||||||
COMMAND_NAME_PAGE=$(head -n1 "$path" | tail -c+3 | tr '-' ' ' | tr '[:upper:]' '[:lower:]')
|
COMMAND_NAME_PAGE=$(head -n1 "$path" | tail -c+3 | sed 's/--//' | tr '.' ' ' | tr '-' ' ' | tr '[:upper:]' '[:lower:]')
|
||||||
|
|
||||||
# Check if there is a mismatch between filename and content command names
|
# Check if there is a mismatch between filename and content command names
|
||||||
if [ "$COMMAND_NAME_FILE" != "$COMMAND_NAME_PAGE" ]; then
|
if [[ "$COMMAND_NAME_FILE" != "$COMMAND_NAME_PAGE" && ! ${IGNORE_LIST[*]} =~ $COMMAND_NAME_PAGE ]]; then
|
||||||
echo "Inconsistency found in file: $path: $COMMAND_NAME_PAGE should be $COMMAND_NAME_FILE" >> "$OUTPUT_FILE"
|
echo "Inconsistency found in file: $path: $COMMAND_NAME_PAGE should be $COMMAND_NAME_FILE" >> "$OUTPUT_FILE"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue