On 3/6/07, Francis Avila <[EMAIL PROTECTED]> wrote:
> This patch fixes the seq fallback seq.in (but it also should apply
> cleanly to seq) to properly handle negative step arguments.
>
> (Note that seq won't work with any negative arguments unless you
> source it because of the option parsing bug I posted about.)

Nicely spotted. I'll try the patch out when I get home next week.

> --
> Francis Avila
>
> seq.in.diff follows:
>
> --- ./seq.in    2007-02-08 12:38:58.000000000 -0500
> +++ /Users/favila/seq.in        2007-03-06 12:07:43.000000000 -0500
> @@ -45,4 +45,24 @@
>         end
> end
> -echo "for( i=$from; i<=$to ; i+=$step ) i;" | bc
> +#Tries to replicate gseq (GNU coreutils) 6.7 behavior.
> +# If $from <= $to and $step == 0, gseq prints $from forever. (!!)
> +#
> +# Could not replicate inconsistent behavior when $from > $to and
> $step < 0
> +# when ends exactly on $to:
> +# > gseq 10 -.9 1
> +# 10.0 9.1 8.2 7.3 6.4 5.5 4.6 3.7 2.8 1.9 #No 1.0
> +# > gseq 2 -.1 1
> +# 2.0 1.9 1.8 1.7 1.6 1.5 1.4 1.3 1.2 1.1 1.0 #But 1.0 here
> +# Probably caused by base 2 fractional misrepresentation?
> +# bc has no problem because it works in base 10.
> +
> +#POSIX bc doesn't have 'else'
> +set -l bccmd "if ($step < 0) {
> +    for( i=$from; i>=$to ; i+=$step ) i;
> +}
> +if ($step >= 0) {
> +    for( i=$from; i<=$to ; i+=$step ) i;
> +}"
> +
> +echo $bccmd | bc
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Fish-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/fish-users
>


-- 
Axel

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to