On 4/19/06, Axel Liljencrantz <[EMAIL PROTECTED]> wrote:
> On 4/19/06, ray hammond <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > I am using Fedora Core 5, fish version 1.21.4.
> >
> >
> >
> > I have the following shell script which cycles through pretty colours on my
> > terminal.
> >
> >
> >
> > #!/bin/bash
> >
> > #
> >
> > # "colsel" - a term color selector
> >
> >
> >
> > for n in `seq 40 47`
> >
> > do
> >
> >     for m in `seq 30 37`
> >
> >     do
> >
> >         echo -en "\E[$m;${n}m"
> >
> >         clear
> >
> >         echo $n $m
> >
> >         read
> >
> >     done
> >
> > done
> >
> >
> >
> > I've attempted to convert this for usage under the fish shell.  I ended u
> > with:
> >
> >
> >
> > #!/usr/bin/fish
> >
> > #
> >
> > # "colsel" - a term color selector
> >
> >
> >
> > for n in `seq 40 47`;
> >
> >     for m in `seq 30 37`;
> >
> >         echo -en "\E[$m;${n}m"
> >
> >         clear
> >
> >         echo $n $m
> >
> >         read
> >
> >     end;
> >
> > end;
> >
> >
> > When I run the script a get no colours, plus the read command appears not to
> > work.
>
> There are a few minor problems with this script left:
>
> * Fish uses () for command substitution, not ``. So the for-loops
> should be 'for n in (seq 40 47)', etc..
>
> * Fish does not recognize the ${FOO} syntax for variable expansion,
> only $FOO. If you want to append a string to a variable, you can
> enclose the variable expansion in a brace expansion '{$FOO}bar', the
> brace expansion will of course expand to only the variable, but the
> 'bar' will not be considered a part of the variable name.
>
> * Fish uses /bin/echo as it's echo implementation, while bash has a
> builtin implementation which behaves differently. Specifically,
> /bin/echo does not know about \e to mean the escape character. Fish
> itself does however know about \e, and a huge number of other escapes.
> Fish even understands Unicode escapes like \u2026. You can only use
> backslash escapes in fish in an unquoted context (e.g. not within ""),
> so you can substitute your string with 'echo \e\[$m\;{$n}m'.
>
> * The fish read implementation expects at least one variable name to
> read into. It makes sense to use read simply as a pause-program, and
> discard all input, I's simply never considered that fact that one
> might want to. I'll fix this, but until that happens, you can replace
> 'read' with 'read tmp'.

I've fixed this. Updated version is in the Darcs repo.

>
> After fixing this issues, you script works for a while, until it
> stumbles across some weird fish bug and crashes. Oops. I'll look into
> this asap.

Looked into this. Turns out that fish does not initialize the history
list when starting in non-interractive mode, but the read builtin
actually uses the history, meaning things will get corrupted. Fixed in
the Darcs repo. The fish read builtin is actually pretty cool, IMO, it
supports copy-and-paste, it has it's own history list, etc..

>
> --
> Axel
>

--
Axel


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to