Monday, August 1, 2011

Re: sh vs bash syntax coloring

Reply to message «Re: sh vs bash syntax coloring»,
sent 12:31:16 01 August 2011, Monday
by ranousse@gmx.com:

> In the first case
> I would like like that :!shell_cmd is runed with bash.
> (In fact the main reason is that sometimes I write things like
>
> :!action="xpdf -option"; ...; $action file
>
> and by default zsh does not split $action in 2 strings, there's an
> option but it needs one more command).
You can put this option somewher in ~/.zshenv. Or, better, use zsh syntax for
it:
!action=(xpdf -option) ; ... ; $action file
!action="xpdf -option" ; ... ; ${(z)action} file
!action="xpdf -option" ; ... ; $=action file
in last case it is just one more character to type, in the first case you should
type exactly the same number of characters, but two of them are different. These
methods are not the same under all circumstances, but are the same here.
I actually hate using bash for scripting: how do you like using
command "${array[@]}"
where in zsh you type just
command $array
. You have to also turn your mind on remembering that you must use quotes around
any parameter if you want it to come in one piece and unmodified.

I would likely choose zsh, perl, python for scripting but not bash.

Original message:
> On 31/07 13:10, Gary Johnson wrote:
> > I'm not sure I understand the problem. If you write your shell
> > scripts with
> >
> > #!/bin/bash
> >
> > as the first line, they will be executed by bash, regardless of the
> > shell they were started from.
>
> My problem with #!/bin/bash and #!/bin/sh is solved. Actually it did not
> concerned wich shell is used to run the script but the syntax
> highlighting. I have no problem about wich shell is used to run the
> script.
>
> My question about which shell is used between bash and zsh concerns
>
> :!shell_cmd and :sh.
>
> In the first case
> I would like like that :!shell_cmd is runed with bash.
> (In fact the main reason is that sometimes I write things like
>
> :!action="xpdf -option"; ...; $action file
>
> and by default zsh does not split $action in 2 strings, there's an
> option but it needs one more command).
>
> And for :sh, as it's a classical interactive shell, I would prefer zsh.
>
> > What behavior do you want from
> >
> > :!shell_command
> >
> > that you get from bash that you don't get from zsh?
> > You could create a ~/.bashrc that contains just
> >
> > exec /bin/zsh
> >
> > and that would start zsh as your interactive shell, but I don't know
> > whether the behavior would be the same as if you executed ":sh" with
> > sh=zsh.
>
> This seems to work. But I loose the possibility of running interactive
> bash if I want. Interesting however.

No comments: