-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix parent dir bugs (#346), pwd bugs, add regression tests
- Loading branch information
1 parent
98b087a
commit 22c230c
Showing
4 changed files
with
44 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
function _tide_parent_dirs --on-variable PWD | ||
set -g _tide_parent_dirs (for dir in (string split / $PWD) | ||
set -la parts $dir | ||
string join / $parts | ||
end) | ||
set -g _tide_parent_dirs (string escape ( | ||
for dir in (string split / -- $PWD) | ||
set -la parts $dir | ||
string join / -- $parts | ||
end)) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# RUN: %fish %s | ||
_tide_parent_dirs | ||
|
||
function _parent_dirs -a dir | ||
cd $dir | ||
eval "set _tide_parent_dirs $_tide_parent_dirs" | ||
path is $_tide_parent_dirs/test.foo && echo found | ||
end | ||
|
||
set -l tmpdir (mktemp -d) | ||
|
||
mkdir -p "$tmpdir/tmp/has spaces/foo" | ||
_parent_dirs "$tmpdir/tmp/has spaces/foo" # CHECK: | ||
touch "$tmpdir/tmp/has spaces/test.foo" | ||
_parent_dirs "$tmpdir/tmp/has spaces/foo" # CHECK: found | ||
|
||
mkdir -p "$tmpdir/tmp/--has dashes/foo" | ||
_parent_dirs "$tmpdir/tmp/--has dashes/foo" # CHECK: | ||
touch "$tmpdir/tmp/--has dashes/test.foo" | ||
_parent_dirs "$tmpdir/tmp/--has dashes/foo" # CHECK: found | ||
|
||
mkdir -p "$tmpdir/tmp/has'quotes''/foo" | ||
_parent_dirs "$tmpdir/tmp/has'quotes''/foo" # CHECK: | ||
touch "$tmpdir/tmp/has'quotes''/test.foo" | ||
_parent_dirs "$tmpdir/tmp/has'quotes''/foo" # CHECK: found | ||
|
||
command rm -r $tmpdir |