diff --git a/opt/cs50/lib/help50/bash b/opt/cs50/lib/help50/bash index 61521b7..4bd0fa1 100755 --- a/opt/cs50/lib/help50/bash +++ b/opt/cs50/lib/help50/bash @@ -37,6 +37,14 @@ if [[ "$output" =~ $regex ]]; then exit fi +# touch foo && cd foo +regex="bash: cd: (.*): Not a directory" +if [[ "$output" =~ $regex ]]; then + file="${BASH_REMATCH[1]}" + echo "Looks like you're trying to change directories, but \`$file\` isn't a directory." + exit +fi + # touch foo.c && ./foo.c regex="bash: \./(([^:]*)\.c): Permission denied" if [[ "$output" =~ $regex ]]; then diff --git a/opt/cs50/lib/help50/cd b/opt/cs50/lib/help50/cd index 0722752..8fa9262 100755 --- a/opt/cs50/lib/help50/cd +++ b/opt/cs50/lib/help50/cd @@ -18,3 +18,10 @@ if [[ "$output" =~ $regex ]]; then echo fi fi + +# cd.. || cd. +regex="bash: cd\.\.?: command not found" +if [[ "$output" =~ $regex ]]; then + echo "Did you mean to run \`cd ..\` instead?" + exit +fi diff --git a/opt/cs50/lib/help50/make b/opt/cs50/lib/help50/make index 347f51b..db79c38 100755 --- a/opt/cs50/lib/help50/make +++ b/opt/cs50/lib/help50/make @@ -9,7 +9,7 @@ if [[ "$output" =~ $regex ]]; then # If target is a directory if [[ -d "${BASH_REMATCH[1]}" ]]; then - echo "Cannot run \`make\` on a directory. Did you mean to run \`cd ${BASH_REMATCH[1]}\`?" + echo "Cannot run \`make\` on a directory. Did you mean to run \`cd ${BASH_REMATCH[1]}\` instead?" exit fi @@ -17,7 +17,7 @@ if [[ "$output" =~ $regex ]]; then if [[ "${BASH_REMATCH[1]}" == *?.c ]]; then base="${BASH_REMATCH[1]%.c}" if [[ -n "$base" && ! -d "$base" ]]; then - echo "Did you mean to run \`make ${base}\`?" + echo "Did you mean to run \`make ${base}\` instead?" exit fi fi @@ -28,7 +28,8 @@ regex="make: \*\*\* No rule to make target '(.*)'" if [[ "$output" =~ $regex ]]; then # If no .c file for target - file="${BASH_REMATCH[1]}.c" + file="${BASH_REMATCH[1]}" + [[ "$file" == *.c ]] || file="$file.c" if [[ ! -f "$file" ]]; then # Search recursively for .c file