mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Revert "Use BC_LINE_LENGTH=2 for bc."
This would fail on very long numbers, e.g.
`math "1 + 1233242342353453463458972349873489273984873289472914712894791824712941"`
would now return "42", where it previously returned the correct "1233242342353453463458972349873489273984873289472914712894791824712942".
This reverts commit 26e781ef5a
.
This commit is contained in:
parent
bd93a9e6ff
commit
11f4e64e45
1 changed files with 3 additions and 6 deletions
|
@ -21,12 +21,9 @@ function math --description "Perform math calculations in bc"
|
||||||
return 2 # no arguments is an error
|
return 2 # no arguments is an error
|
||||||
end
|
end
|
||||||
|
|
||||||
# With BC_LINE_LENGTH set to 2, the first line is a slash and the following line can be arbitrarily long.
|
# Stitch lines together manually. We can't rely on BC_LINE_LENGTH because some systems don't
|
||||||
# We can't set this to 0 because some systems don't have a new enough version of bc.
|
# have a new enough version of bc.
|
||||||
set -lx BC_LINE_LENGTH 2
|
set -l out (echo "scale=$scale; $argv" | bc | string replace -r '\\\\$' '' | string join '')
|
||||||
set -l out (echo "scale=$scale; $argv" | bc)
|
|
||||||
set -q out[2]
|
|
||||||
and set out $out[2]
|
|
||||||
switch "$out"
|
switch "$out"
|
||||||
case ''
|
case ''
|
||||||
# No output indicates an error occurred.
|
# No output indicates an error occurred.
|
||||||
|
|
Loading…
Reference in a new issue