File tree 1 file changed +14
-2
lines changed
1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -31,14 +31,26 @@ if [[ "$output" =~ $regex ]]; then
31
31
fi
32
32
fi
33
33
34
- # mkdir foo && touch foo/bar.py && python bar .py
34
+ # mkdir -p foo/bar && touch foo/bar/baz .py && python baz .py
35
35
regex=" python: can't open file '(.*\.py)': \[Errno 2\] No such file or directory"
36
36
if [[ " $output " =~ $regex ]]; then
37
37
38
38
# Relative path from $PWD
39
39
path=$( realpath --relative-to=. " ${BASH_REMATCH[1]} " )
40
40
41
- # If .py is in $PWD
41
+ # If command was `python baz.py` (i.e., without a dirname)
42
+ if [[ -n " $path " && " $path " == $( basename " $path " ) ]]; then
43
+ dir=$( _find -type f " $path " )
44
+ echo -n " There isn't a file called \` $path \` in your current directory."
45
+ if [[ ! -z " $dir " ]]; then
46
+ echo " Did you mean to \` cd $dir \` first?"
47
+ else
48
+ echo
49
+ fi
50
+ exit
51
+ fi
52
+
53
+ # If command was `python bar/baz.py` (i.e., with a dirname)
42
54
if [[ -n " $path " && " $path " == $( basename " $path " ) ]]; then
43
55
dir=$( _find -type f " $path " )
44
56
echo -n " There isn't a file called \` $path \` in your current directory."
You can’t perform that action at this time.
0 commit comments