Skip to content

Commit

Permalink
detecting miscapitalized commands
Browse files Browse the repository at this point in the history
  • Loading branch information
dmalan committed Jul 2, 2024
1 parent 3192a87 commit aa21d92
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions opt/cs50/lib/help50/bash
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ if [[ "$output" =~ $regex ]]; then
exit
fi

# If uppercase
argv0="${BASH_REMATCH[1],,}" # Lowercase it
if command -v "$argv0" &> /dev/null; then
echo "Did you mean to run \`$argv0\`, in lowercase instead?"
exit
fi

# If backslash instead of forward slash
if [[ "${BASH_REMATCH[1]}" =~ ^\.(.*) ]]; then
if [[ -f "./${BASH_REMATCH[1]}" ]]; then
Expand Down

0 comments on commit aa21d92

Please sign in to comment.