On 1/22/06, Claes Nästén <[EMAIL PROTECTED]> wrote:
> On Sun, Jan 22, 2006 at 09:36:52PM +0900, Hiroshi SAKURAI wrote:
> > Hi
> >
> > When I try to complete ls command, error occurs.
> >
> > $ ls -<TAB>
> > fish: Unknown command 'seq'
> > /usr/local/etc/fish.d/completions/ls.fish (line 1): seq (count $argv)
> >
> > The cause of the error is that NetBSD 2.x does't have 'seq'.
> > 'seq' first appears on NetBSD 3.0 that was released last December.
> >
> Same goes for Solaris, accoarding to the FreeBSD Hypertext Man Pages
> http://www.freebsd.org/cgi/man.cgi it did not match in FreeBSD or OpenBSD
> either.
> >
> > It would be nice if fish have builtin_seq.
> >
> Or atleast a int only builtin_seq?
According to the FreeBSD man pages, both these systems have bc. So
this shellscript should work:
function seq -d "Print a sequnce of numbers"
set -l from 1
set -l step 1
set -l to 1
switch (count $argv)
case 1
set to $argv[1]
case 2
set from $argv[1]
set to $argv[2]
case 3
set from $argv[1]
set step $argv[2]
set to $argv[3]
case '*'
printf (_ "%s: Expected 1, 2 or 3 arguments, got %d\n")
seq (count $argv)
return 1
end
for i in $from $step $to
if not echo $i | grep '^-\?[0-9]*\(\|.[0-9]\+\)$' >/dev/null
printf (_ "%s: '%s' is not a number\n") seq $i
return 1
end
end
echo "for( i=$from; i<$to ; i+=$step ) i;" | bc
end
It handles most the things regular seq does. I guess it could be
included with fish inside a test for a regular seq.
> >
> > Thanks.
> >
> > --
> > Hiroshi SAKURAI
> > http://vimrc.hp.infoseek.co.jp/
> >
>
> --
> Claes Nästén, <[EMAIL PROTECTED]>, http://www.pekdon.net/
>
--
Axel
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users