2012/6/1 Maxim Gonchar <gma...@gmail.com>
> Right,
>
> the only difficulty is 'if statement'.
>
> in bash you could do something like this:
> if cmd1 args1 && cmd2 args2 && cmd3 args3
> then
> #some code
> fi
>
> But for fish it is not the case, because 'if' is the command as well.
> It took some time for me to understand that I can do this in fish in the
> following way:
> cmd1 args1; and cmd2 args2
> if and cmd3 args3
> #some code
> end
>
Cool. I hadn't though of doing it that way. What I usually do, which is
significantly wordier, but (to me) a bit more readable is:
if begin; cmd1args1; and cmd2 args2; and cmd3 arg3; end
#some code
end
A begin/end block of commands can actually be used for pretty much
everything a regular command can be used for, e.g. output redirection, used
as an element in a pipe.
Axel
> regards,
> Maxim
>
> On Fri, 01 Jun 2012 04:22:56 +0400, Philip Ganchev
> <phil.ganc...@gmail.com> wrote:
>
> > On Thu, May 31, 2012 at 12:14 AM, ridiculous_fish
> > <corydo...@ridiculousfish.com> wrote:
> >>
> >> On May 30, 2012, at 1:17 PM, Maxim Gonchar wrote:
> >>
> > [...]
> >> 4. I think fish is doing the right thing with "false ; and sdlkfjsdklf".
> >> That semicolon means that the 'and' is the beginning of a new
> >> statement, and
> >> fish agrees with other shells (including fish trunk) that this is an
> >> error.
> >> Remove the semicolon ("false and sdlkfjdsklf") and it does not error.
> >>
> >> This statement confronts all my fish experience. I use fish as default
> >> shell
> >> for the long time.
> >> What about "echo 123 and echo 234" and "echo 123; and echo 234"?
> >
> > If I might add to that: having 'and', 'or' and 'not' as separate
> > commands seems conceptually simpler to me. Also, it is more useful for
> > interactive use, because you can start executing a command like 'foo'
> > and then add 'and bar'.
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Fish-users mailing list
> Fish-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/fish-users
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users