-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from gazorby/fd-auto-strip-cwd
Auto strip cwd prefix if fd >= 8.3.0
- Loading branch information
Showing
4 changed files
with
57 additions
and
5 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
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,18 @@ | ||
function _fifc_test_version -d "Compare version numbers" | ||
set -l arg_1 (string replace --regex --all '[^\d]' '' -- "$argv[1]") | ||
set -l arg_2 (string replace --regex --all '[^\d]' '' -- "$argv[3]") | ||
set -l op "$argv[2]" | ||
|
||
set -l v_diff (math (string length -- $arg_1) - (string length -- $arg_2)) | ||
|
||
# Ensure both versions are the same length | ||
if test $v_diff -gt 0 | ||
set arg_2 (string join '' -- "$arg_2" (string repeat -N -n $v_diff '0')) | ||
else if test $v_diff -lt 0 | ||
set v_diff (math abs $v_diff) | ||
set arg_1 (string join '' -- "$arg_1" (string repeat -N -n $v_diff '0')) | ||
end | ||
|
||
set -l cmd (string collect -- "test " "$arg_1" " $op " "$arg_2") | ||
eval $cmd | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
set -l actual (_fifc_test_version "3.4" -gt "3.0") | ||
@test "version test basic gt" $status = 0 | ||
|
||
set -l actual (_fifc_test_version "3.4" -ge "3.4") | ||
@test "version test basic ge equal" $status = 0 | ||
|
||
set -l actual (_fifc_test_version "3.5" -ge "3.4") | ||
@test "version test basic ge greater" $status = 0 | ||
|
||
set -l actual (_fifc_test_version "3.4" -lt "3.5") | ||
@test "version test basic lt" $status = 0 | ||
|
||
set -l actual (_fifc_test_version "3.4" -le "3.4") | ||
@test "version test basic le equal" $status = 0 | ||
|
||
set -l actual (_fifc_test_version "3.4" -le "3.5") | ||
@test "version test basic le lower" $status = 0 | ||
|
||
set -l actual (_fifc_test_version "3.4" -gt "3") | ||
@test "version test length not equal" $status = 0 | ||
|
||
set -l actual (_fifc_test_version "3.4" -gt "3") | ||
@test "version test length not equal 1" $status = 0 | ||
|
||
set -l actual (_fifc_test_version "3" -gt "3.4") | ||
@test "version test length not equal 2" $status = 1 | ||
|
||
set -l actual (_fifc_test_version "fish 3.5.0" -gt "3.4.2") | ||
@test "version test extract version left" $status = 0 | ||
|
||
set -l actual (_fifc_test_version "3.5.0" -gt "fish 3.4.2") | ||
@test "version test extract version right" $status = 0 |