mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-10 23:24:39 +00:00
Use the math function instead of calling bc directly in various places
darcs-hash:20061212171118-ac50b-a40709edf008f3d725e3755d5282ae5a84818c88.gz
This commit is contained in:
parent
b3fa76c1be
commit
fd11f294bc
3 changed files with 9 additions and 7 deletions
|
@ -32,7 +32,7 @@ function __fish_print_packages
|
|||
set cache_file /tmp/.rpm-cache.$USER
|
||||
if test -f $cache_file
|
||||
cat $cache_file
|
||||
set age (echo (date +%s) - (stat -c '%Y' $cache_file) | bc)
|
||||
set age (math (date +%s) - (stat -c '%Y' $cache_file))
|
||||
set max_age 250
|
||||
if test $age -lt $max_age
|
||||
return
|
||||
|
|
|
@ -12,7 +12,7 @@ function dirh -d (N_ "Print the current directory history (the back- and fwd- li
|
|||
# Avoid set comment
|
||||
set -l current (command pwd)
|
||||
set -l separator " "
|
||||
set -l line_len (echo (count $dirprev) + (echo $dirprev $current $dirnext | wc -m) | bc)
|
||||
set -l line_len (math (count $dirprev) + (echo $dirprev $current $dirnext | wc -m) )
|
||||
if test $line_len -gt $COLUMNS
|
||||
# Print one entry per line if history is long
|
||||
set separator "\n"
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
function __fish_umask_parse -d "Internal umask function"
|
||||
# Test if already a valid octal mask, and pad it with zeros
|
||||
if echo $argv | sgrep -E '^(0|)[0-7]{1,3}$' >/dev/null
|
||||
for i in (seq (echo 5-(echo $argv|wc -c)|bc)); set argv 0$argv; end
|
||||
set -l char_count (echo $argv| wc -c)
|
||||
for i in (seq (math 5 - $char_count)); set argv 0$argv; end
|
||||
echo $argv
|
||||
else
|
||||
# Test if argument really is a valid symbolic mask
|
||||
|
@ -22,7 +23,8 @@ function __fish_umask_parse -d "Internal umask function"
|
|||
|
||||
for i in 1 2 3
|
||||
set tmp (echo $tmp|cut -c 2-)
|
||||
set res[$i] (echo 7-(echo $tmp|cut -c 1)|bc)
|
||||
set -l char_count (echo $tmp|cut -c 1)
|
||||
set res[$i] (math 7 - $char_count)
|
||||
end
|
||||
|
||||
set -l el (echo $argv|tr , \n)
|
||||
|
@ -80,10 +82,10 @@ function __fish_umask_parse -d "Internal umask function"
|
|||
set val 4
|
||||
end
|
||||
if echo $i |sgrep 'w' >/dev/null
|
||||
set val (echo $val + 2|bc)
|
||||
set val (math $val + 2)
|
||||
end
|
||||
if echo $i |sgrep 'x' >/dev/null
|
||||
set val (echo $val + 1|bc)
|
||||
set val (math $val + 1)
|
||||
end
|
||||
|
||||
for j in $idx
|
||||
|
@ -101,7 +103,7 @@ function __fish_umask_parse -d "Internal umask function"
|
|||
end
|
||||
|
||||
for i in 1 2 3
|
||||
set res[$i] (echo 7-$res[$i]|bc)
|
||||
set res[$i] (math 7 - $res[$i])
|
||||
end
|
||||
echo 0$res[1]$res[2]$res[3]
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue