mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 05:28:49 +00:00
deal with BC_LINE_LENGTH not being honored
FreeBSD 12, Dragonfly BSD, and presumably other BSDs don't recognize the BC_LINE_LENGTH env var and might split the output at 70 chars. Fixes #3414
This commit is contained in:
parent
e5bfdb99b6
commit
4223b3da68
1 changed files with 6 additions and 3 deletions
|
@ -22,11 +22,14 @@ function math --description "Perform math calculations in bc"
|
|||
end
|
||||
|
||||
# Set BC_LINE_LENGTH to a ridiculously high number so it only uses one line for most results.
|
||||
# Results with more digits than that are basically never used anyway.
|
||||
# We can't use 0 since some systems (including macOS) use an ancient bc that doesn't support it.
|
||||
# 32767 should still work on 2-byte int systems, though this is untested.
|
||||
set -lx BC_LINE_LENGTH 32767
|
||||
# We also can't count on this being recognized since some BSD systems don't recognize this env
|
||||
# var at all and limit the line length to 70.
|
||||
set -lx BC_LINE_LENGTH 500
|
||||
set -l out (echo "scale=$scale; $argv" | bc)
|
||||
if set -q out[2]
|
||||
set out (string join '' (string replace \\ '' $out))
|
||||
end
|
||||
switch "$out"
|
||||
case ''
|
||||
# No output indicates an error occurred.
|
||||
|
|
Loading…
Reference in a new issue