File tree Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,14 @@ if [[ "$output" =~ $regex ]]; then
37
37
exit
38
38
fi
39
39
40
+ # touch foo && cd foo
41
+ regex=" bash: cd: (.*): Not a directory"
42
+ if [[ " $output " =~ $regex ]]; then
43
+ file=" ${BASH_REMATCH[1]} "
44
+ echo " Looks like you're trying to change directories, but \` $file \` isn't a directory."
45
+ exit
46
+ fi
47
+
40
48
# touch foo.c && ./foo.c
41
49
regex=" bash: \./(([^:]*)\.c): Permission denied"
42
50
if [[ " $output " =~ $regex ]]; then
Original file line number Diff line number Diff line change @@ -18,3 +18,10 @@ if [[ "$output" =~ $regex ]]; then
18
18
echo
19
19
fi
20
20
fi
21
+
22
+ # cd.. || cd.
23
+ regex=" bash: cd\.\.?: command not found"
24
+ if [[ " $output " =~ $regex ]]; then
25
+ echo " Did you mean to run \` cd ..\` instead?"
26
+ exit
27
+ fi
Original file line number Diff line number Diff line change @@ -9,15 +9,15 @@ if [[ "$output" =~ $regex ]]; then
9
9
10
10
# If target is a directory
11
11
if [[ -d " ${BASH_REMATCH[1]} " ]]; then
12
- echo " Cannot run \` make\` on a directory. Did you mean to run \` cd ${BASH_REMATCH[1]} \` ?"
12
+ echo " Cannot run \` make\` on a directory. Did you mean to run \` cd ${BASH_REMATCH[1]} \` instead ?"
13
13
exit
14
14
fi
15
15
16
16
# If target ends with .c
17
17
if [[ " ${BASH_REMATCH[1]} " == *? .c ]]; then
18
18
base=" ${BASH_REMATCH[1]% .c} "
19
19
if [[ -n " $base " && ! -d " $base " ]]; then
20
- echo " Did you mean to run \` make ${base} \` ?"
20
+ echo " Did you mean to run \` make ${base} \` instead ?"
21
21
exit
22
22
fi
23
23
fi
@@ -28,7 +28,8 @@ regex="make: \*\*\* No rule to make target '(.*)'"
28
28
if [[ " $output " =~ $regex ]]; then
29
29
30
30
# If no .c file for target
31
- file=" ${BASH_REMATCH[1]} .c"
31
+ file=" ${BASH_REMATCH[1]} "
32
+ [[ " $file " == * .c ]] || file=" $file .c"
32
33
if [[ ! -f " $file " ]]; then
33
34
34
35
# Search recursively for .c file
You can’t perform that action at this time.
0 commit comments