Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatibility with fish 3 #91

Merged
merged 2 commits into from
Dec 9, 2018
Merged

Conversation

faho
Copy link
Contributor

@faho faho commented Dec 7, 2018

Hi!

The upcoming fish 3 has a rather large number of changes, some of them not entirely backwards compatible.

Among them:

  • ^ to redirect stderr is deprecated and can be turned off via a new "feature flags" system. The intention is to default it to off in the next major release after 3.0, and to remove it entirely in the one after that.

  • math is now a builtin (which makes pure about 5x faster), and defaults to float output (with trailing 0s removed - so e.g. 5.0000 will come out as 5)

Pure hits both of this, this PR rectifies that.

I'm not sure if you still support fish < 2.4 (meaning 2.3, as that's what introduced string), the second commit requires 2.4. If you prefer, I can add a solution using string that's a teensy bit uglier.

The former is deprecated in fish 3.0, and can even optionally be
turned off.
Fish 3's new math builtin defaults to float output (with trailing 0s
removed), and modulo on things with a non-integer component retains
that component, i.e.

    math 3 % 2 # is 1
    math 3.5 % 2 # is 1.5 - the ".5" is just not touched

This requires fish 2.4.0, I'm not sure if anything else in pure does.

Alternatively, one could `string replace -r '\..*' ''` on every math
call here.
set -l minutes (math "$milliseconds / 60000 % 60")
set -l hours (math "$milliseconds / 3600000 % 24")
set -l days (math "$milliseconds / 86400000")
set -l seconds (math -s0 "$milliseconds / 1000 % 60")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind using long option format in order to make code less cryptic and easier to contribute to?

Suggested change
set -l seconds (math -s0 "$milliseconds / 1000 % 60")
set -l seconds (math --scale=0 "$milliseconds / 1000 % 60")

Copy link
Contributor Author

@faho faho Dec 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't, because fish 2.4.0's math actually does not support that. So that would bump the required version to 2.7.0 (the first (and only) version of math to use argparse).

set -l hours (math "$milliseconds / 3600000 % 24")
set -l days (math "$milliseconds / 86400000")
set -l seconds (math -s0 "$milliseconds / 1000 % 60")
set -l minutes (math -s0 "$milliseconds / 60000 % 60")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set -l minutes (math -s0 "$milliseconds / 60000 % 60")
set -l minutes (math --scale=0 "$milliseconds / 60000 % 60")

set -l days (math "$milliseconds / 86400000")
set -l seconds (math -s0 "$milliseconds / 1000 % 60")
set -l minutes (math -s0 "$milliseconds / 60000 % 60")
set -l hours (math -s0 "$milliseconds / 3600000 % 24")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set -l hours (math -s0 "$milliseconds / 3600000 % 24")
set -l hours (math --scale=0 "$milliseconds / 3600000 % 24")

set -l seconds (math -s0 "$milliseconds / 1000 % 60")
set -l minutes (math -s0 "$milliseconds / 60000 % 60")
set -l hours (math -s0 "$milliseconds / 3600000 % 24")
set -l days (math -s0 "$milliseconds / 86400000")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set -l days (math -s0 "$milliseconds / 86400000")
set -l days (math --scale=0 "$milliseconds / 86400000")

@edouard-lopez
Copy link
Member

edouard-lopez commented Dec 9, 2018

Our CI runs on Ubuntu trusty/14.04.5 and install from ppa:fish-shell/release-2. That means tests are run against

fish - 2.7.1-1~trusty 

Our package manager tests suite runs on a container based on colstrom/fish image which, as of today, runs with 2.7.1:

❯ docker run --rm colstrom/fish --version
fish, version 2.7.1
❯ docker run --rm edouardlopez/pure-fish fish --version
fish, version 2.7.1 

My opinion is to officially support only the versions against our tests run, i.e. to this date, only 2.7.1.

So I there is no reason to block this issue on this matter.

We can discuss this further in a dedicated issue #93.

@edouard-lopez
Copy link
Member

Thanks didn't notice that.

For now, I will add a requirement for fish ≥2.4

However, why do you mention the 2.4 as a minimum? What is fish release lifecycle?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants