Loading ...
Sorry, an error occurred while loading the content.
 

Re: sh vs bash syntax coloring

Expand Messages
  • ranousse@gmx.com
    ... Ok thank you. I think this will be sufficient for my need. Actually I didn t say bash was better than zsh, but I learnt sh syntax first (not even bash, so
    Message 1 of 18 , Aug 1, 2011
      > 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.

      Ok thank you. I think this will be sufficient for my need.
      Actually I didn't say bash was better than zsh, but I learnt sh syntax
      first (not even bash, so no array at all it seems) and I don't know zsh
      one. I only write small scripts ;-)
      But I'm sure you're right.

      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    • Leiking
      zsh. ... -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you are replying to. For more information,
      Message 2 of 18 , Aug 1, 2011
        zsh.

        2011/8/1 <ranousse@...>:
        >> 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.
        >
        > Ok thank you. I think this will be sufficient for my need.
        > Actually I didn't say bash was better than zsh, but I learnt sh syntax
        > first (not even bash, so no array at all it seems) and I don't know zsh
        > one. I only write small scripts ;-)
        > But I'm sure you're right.
        >
        > --
        > You received this message from the "vim_use" maillist.
        > Do not top-post! Type your reply below the text you are replying to.
        > For more information, visit http://www.vim.org/maillist.php
        >

        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php
      • Benjamin R. Haskell
        ... Yes, they are: http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html $(command) - #tag_02_06_03 - command substitution $((n+1)) -
        Message 3 of 18 , Aug 1, 2011
          On Sun, 31 Jul 2011, Thilo Six wrote:

          > ranousse@... wrote the following on 31.07.2011 12:42
          >
          > Hello
          >
          >> I'm not very happy with syntax coloring of sh scripts (starting with
          >> #!/bin/sh). For example, things like $(command), $((n+1)) or
          >> ${var%.txt} are very badly displayed. However they are part of POSIX
          >> sh I think.

          Yes, they are:

          http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html
          $(command) - #tag_02_06_03 - command substitution
          $((n+1)) - #tag_02_06_04 - arithmetic expansion
          ${var%.txt} - #tag_02_06_02 (last ¶) - parameter expansion


          >> Do you know a simple hack to correct this. Something that could
          >> interest me would be always using bash syntax coloring even with
          >> #!/bin/sh at the beginning.
          >>
          >> I thought of modelines but vim seems to use the same syntax file for
          >> sh and bash and thus I cannot use something like
          >> # vi: syntax=bash
          >> or
          >> # vi: ft=bash
          >>
          >
          >
          > ,----[ :h ft-sh-syntax ]----------------------
          >
          > < bash: >
          > let g:is_bash = 1
          > `---------------------------------------------

          That solves the problem since the OP wants bash syntax. I don't. Is
          there a reason the constructs mentioned aren't included in "plain 'sh'"
          mode?

          --
          Best,
          Ben

          --
          You received this message from the "vim_use" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php
        • Charles Campbell
          ... Just to be complete, please read :help ft-syntax-sh (g:is_bash is covered there, for example). Regards, Chip Campbell -- You received this message from
          Message 4 of 18 , Aug 1, 2011
            ranousse@... wrote:
            > On 31/07 13:49, Thilo Six wrote:
            >
            >> ,----[ :h ft-sh-syntax ]----------------------
            >>
            >> < bash:>
            >> let g:is_bash = 1
            >> `---------------------------------------------
            >>
            > So there is no trick at all, I only have to choose the right option.
            > Thank you very much.
            >
            Just to be complete, please read :help ft-syntax-sh (g:is_bash is
            covered there, for example).

            Regards,
            Chip Campbell

            --
            You received this message from the "vim_use" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php
          • Thilo Six
            Charles Campbell wrote the following on 01.08.2011 18:17 Hello Charles, I think here is a typo: -- -- ... ^ `- s:ft-syntax-sh:ft-sh-syntax: :help
            Message 5 of 18 , Aug 1, 2011
              Charles Campbell wrote the following on 01.08.2011 18:17

              Hello Charles,

              I think here is a typo:

              -- <snip> --

              > Just to be complete, please read :help ft-syntax-sh (g:is_bash is
              ^
              `- s:ft-syntax-sh:ft-sh-syntax:
              ':help ft-syntax-sh' returns E419 to me

              > covered there, for example).
              >
              > Regards,
              > Chip Campbell
              >

              Regards,
              --
              bye Thilo

              4096R/0xC70B1A8F
              721B 1BA0 095C 1ABA 3FC6 7C18 89A4 A2A0 C70B 1A8F


              --
              You received this message from the "vim_use" maillist.
              Do not top-post! Type your reply below the text you are replying to.
              For more information, visit http://www.vim.org/maillist.php
            • ZyX
              Reply to message «Re: sh vs bash syntax coloring», sent 18:28:38 01 August 2011, Monday ... ?
              Message 6 of 18 , Aug 1, 2011
                Reply to message «Re: sh vs bash syntax coloring»,
                sent 18:28:38 01 August 2011, Monday
                by Leiking:

                > zsh.
                ?

                Original message:
                > zsh.
                >
                > 2011/8/1 <ranousse@...>:
                > >> 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.
                > >
                > > Ok thank you. I think this will be sufficient for my need.
                > > Actually I didn't say bash was better than zsh, but I learnt sh syntax
                > > first (not even bash, so no array at all it seems) and I don't know zsh
                > > one. I only write small scripts ;-)
                > > But I'm sure you're right.
                > >
                > > --
                > > You received this message from the "vim_use" maillist.
                > > Do not top-post! Type your reply below the text you are replying to.
                > > For more information, visit http://www.vim.org/maillist.php
              • Charles Campbell
                ... Sorry, that should ve been :help ft-sh-syntax . Regards, Chip Campbell -- You received this message from the vim_use maillist. Do not top-post! Type
                Message 7 of 18 , Aug 1, 2011
                  Thilo Six wrote:
                  > Charles Campbell wrote the following on 01.08.2011 18:17
                  >
                  > Hello Charles,
                  >
                  > I think here is a typo:
                  >
                  > -- <snip> --
                  >
                  >
                  >> Just to be complete, please read :help ft-syntax-sh (g:is_bash is
                  >>
                  > ^
                  > `- s:ft-syntax-sh:ft-sh-syntax:
                  > ':help ft-syntax-sh' returns E419 to me
                  >
                  Sorry, that should've been :help ft-sh-syntax .

                  Regards,
                  Chip Campbell

                  --
                  You received this message from the "vim_use" maillist.
                  Do not top-post! Type your reply below the text you are replying to.
                  For more information, visit http://www.vim.org/maillist.php
                • Simon Nicolussi
                  ... Not all shells support command substitution via $(...), even though it is required by POSIX. The /bin/sh in Solaris comes to mind. If you know you re using
                  Message 8 of 18 , Aug 1, 2011
                    Benjamin R. Haskell wrote:
                    > That solves the problem since the OP wants bash syntax. I don't.
                    > Is there a reason the constructs mentioned aren't included in "plain
                    > 'sh'" mode?

                    Not all shells support command substitution via $(...), even though it
                    is required by POSIX. The /bin/sh in Solaris comes to mind. If you know
                    you're using a compatible shell, you can specify:

                    let g:is_posix = 1

                    --
                    Simon Nicolussi, <Simon.Nicolussi@...>
                    http://homepage.uibk.ac.at/~csag9583/
                  • Benjamin R. Haskell
                    ... [Just FYI:] The /bin/sh in Solaris 10 works fine. Wouldn t surprise me if 5.8 or prior didn t... ... Seems like this should be the default, but okay. I
                    Message 9 of 18 , Aug 1, 2011
                      On Mon, 1 Aug 2011, Simon Nicolussi wrote:

                      > Benjamin R. Haskell wrote:
                      >> That solves the problem since the OP wants bash syntax. I don't. Is
                      >> there a reason the constructs mentioned aren't included in "plain
                      >> 'sh'" mode?
                      >
                      > Not all shells support command substitution via $(...), even though it
                      > is required by POSIX. The /bin/sh in Solaris comes to mind.

                      [Just FYI:] The /bin/sh in Solaris 10 works fine. Wouldn't surprise me
                      if 5.8 or prior didn't...


                      > If you know you're using a compatible shell, you can specify:
                      >
                      > let g:is_posix = 1

                      Seems like this should be the default, but okay. I see it in the help
                      now. Presuming this doesn't affect zsh-detection, I'll just add it and
                      be done.

                      --
                      Thanks,
                      Ben

                      --
                      You received this message from the "vim_use" maillist.
                      Do not top-post! Type your reply below the text you are replying to.
                      For more information, visit http://www.vim.org/maillist.php
                    • Charles Campbell
                      ... You ll also find in the help for ft-sh-syntax the sentence: No need to quote RFCs or market penetration statistics in error reports, please -- just select
                      Message 10 of 18 , Aug 2, 2011
                        Benjamin R. Haskell wrote:
                        > On Mon, 1 Aug 2011, Simon Nicolussi wrote:
                        >
                        >> Benjamin R. Haskell wrote:
                        >>> That solves the problem since the OP wants bash syntax. I don't.
                        >>> Is there a reason the constructs mentioned aren't included in "plain
                        >>> 'sh'" mode?
                        >>
                        >> Not all shells support command substitution via $(...), even though
                        >> it is required by POSIX. The /bin/sh in Solaris comes to mind.
                        >
                        > [Just FYI:] The /bin/sh in Solaris 10 works fine. Wouldn't surprise
                        > me if 5.8 or prior didn't...
                        >
                        >
                        >> If you know you're using a compatible shell, you can specify:
                        >>
                        >> let g:is_posix = 1
                        >
                        > Seems like this should be the default, but okay. I see it in the help
                        > now. Presuming this doesn't affect zsh-detection, I'll just add it
                        > and be done.
                        >
                        You'll also find in the help for ft-sh-syntax the sentence:

                        No need to quote RFCs or market penetration statistics in error
                        reports, please -- just select the default version of the sh your system
                        uses in your <.vimrc>.

                        That's there because posix/ksh users like to quote RFCs about how the
                        default should be is_posix, and bash users like to quote market
                        penetration statistics to insist that the default should be is_bash. I
                        have the Bourne shell as default, not because I particularly like it the
                        best or anything (I'm a is_kornshell user, myself), but to encourage
                        users to make an informed choice.

                        However, please try v117 of sh.vim; it now has some logic using
                        resolve() to attempt to guess which shell is wanted. It won't be
                        perfect; for example, what shell should be used with .profile? On my
                        system, /bin/sh is linked to bash, and so the guessing logic will come
                        up with setting g:is_bash to one; however, my login shell is ksh, and so
                        .profile should be interpreted with g:is_kornshell = 1. The guess will
                        only be made if no g:is_posix, g:is_kornshell, g:is_bash, or g:is_sh exists.

                        You may get v117 from my website:
                        http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax .

                        Regards,
                        Chip Campbell

                        --
                        You received this message from the "vim_use" maillist.
                        Do not top-post! Type your reply below the text you are replying to.
                        For more information, visit http://www.vim.org/maillist.php
                      Your message has been successfully submitted and would be delivered to recipients shortly.