Skip to content

Commit aa21d92

Browse files
committed
detecting miscapitalized commands
1 parent 3192a87 commit aa21d92

File tree

1 file changed

+7
-0
lines changed
  • opt/cs50/lib/help50

1 file changed

+7
-0
lines changed

opt/cs50/lib/help50/bash

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ if [[ "$output" =~ $regex ]]; then
2929
exit
3030
fi
3131

32+
# If uppercase
33+
argv0="${BASH_REMATCH[1],,}" # Lowercase it
34+
if command -v "$argv0" &> /dev/null; then
35+
echo "Did you mean to run \`$argv0\`, in lowercase instead?"
36+
exit
37+
fi
38+
3239
# If backslash instead of forward slash
3340
if [[ "${BASH_REMATCH[1]}" =~ ^\.(.*) ]]; then
3441
if [[ -f "./${BASH_REMATCH[1]}" ]]; then

0 commit comments

Comments
 (0)