I’m moving my posts from Reddit to Lemmy before delete them.

This post is from 2020-09-03.

  • Lemmchen@feddit.de
    link
    fedilink
    English
    arrow-up
    22
    ·
    1 year ago

    Okay, you guys get the once in a liftetime chance to convince me that Bash is not the way to go. I’ll eagerly await your proposals.

    • Like A Duck@programming.dev
      link
      fedilink
      English
      arrow-up
      30
      arrow-down
      2
      ·
      edit-2
      1 year ago

      Zsh, an extended version of the Bourne Shell (sh), offers a plethora of compelling reasons why it surpasses Bash in terms of functionality and customization.

      • Plugin and theme support: Zsh boasts a wide range of plugin frameworks and themes, allowing users to enhance their shell experience and tailor it to their specific needs. The popular Oh-My-Zsh framework is a testament to the vibrant plugin ecosystem available for Zsh.

      • Automatic cd: Zsh simplifies directory navigation by enabling users to change directories simply by typing the name of the desired directory. This feature eliminates the need to type the “cd” command explicitly, saving time and keystrokes.

      • Recursive path expansion: Zsh offers the convenience of shorthand path expansion, allowing users to expand a partial path to its full form recursively. This feature proves particularly useful when dealing with nested directory structures.

      • Spelling correction and approximate completion: Zsh’s intelligent auto-correction feature automatically fixes minor typos in directory names, ensuring smooth and error-free command execution. Additionally, Zsh’s approximate completion feature suggests potential completions based on the entered command, further streamlining the workflow.

      • Syntax highlighting: Zsh goes beyond mere text display by providing syntax highlighting for command lines, making complex commands more readable and easier to comprehend. This feature enhances code visibility and reduces the likelihood of syntax errors.

      • Advanced scripting capabilities: Zsh offers a more powerful scripting language compared to Bash, enabling users to create intricate and sophisticated shell scripts. This flexibility opens up possibilities for automation and complex task execution.

      • Enhanced customization: Zsh provides users with extensive customization options, allowing them to personalize their shell environment to suit their preferences. From prompt customization to theme selection, Zsh empowers users to create a shell experience that aligns with their workflow and aesthetic choices.

      While Zsh undeniably offers a wealth of advantages, it is worth noting that it has a steeper learning curve compared to Bash, especially for users unfamiliar with advanced shell features. Additionally, Zsh consumes more memory due to its more complex data structures and advanced functionality.

    • Gamma@programming.dev
      link
      fedilink
      English
      arrow-up
      6
      ·
      edit-2
      1 year ago

      There are two massive points no one has mentioned yet.

      • Quoting every expansion isn’t necessary in Zsh. Parameters don’t split or glob by default.
      • $array actually expands to every element in an array.

      Compare this between Bash and Zsh:

      a=('/* hello */' 'world!' '  ')
      printf '"%s" ' $a
      
      • Zucca@sopuli.xyz
        link
        fedilink
        English
        arrow-up
        4
        ·
        edit-2
        1 year ago

        $array actually expands to every element in an array.

        Very convenient. But ~every shell script is written in bash or POSIX(y) sh. When I need to write shell scripts I begin with busybox sh compability. If it turns out to be too complex, I’ll convert to bash. This is because if I ever would publish the script it would have better changes to be accepted as a PR for example. Yes. Bash is a mess. I don’t even like it that much. It’s okay. But it’s more standard then zsh. Although I’ve seen the tides turn on some occasions, like macOS.

        Maybe some day I’ll give zsh a second chance.

        • Gamma@programming.dev
          link
          fedilink
          English
          arrow-up
          2
          ·
          1 year ago

          I used to write Bash more than anything, but now the things I write are either simple enough to keep POSIX or complex enough that I miss the extra niceties Zsh provides.

          • zzz@feddit.de
            link
            fedilink
            English
            arrow-up
            1
            ·
            1 year ago

            but now the things I write are either simple enough to keep POSIX or complex enough that I miss the extra niceties Zsh provides.

            Well said!