New favorite tool 😍

  • ReluctantMuskrat@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    3 months ago

    As a long-time bash, awk and sed scripter who knows he’ll probably get downvoted into oblivion for this my recommendation: learn PowerShell

    It’s open-source and completely cross-platform - I use it on Macs, Linux and Windows machines - and you don’t know what you’re missing until you try a fully objected-oriented scripting language and shell. No more parsing text, built-in support for scalars, arrays, hash maps/associative arrays, and more complex types like version numbers, IP addresses, synchronized dictionaries and basically anything available in .Net. Read and write csv, json and xml natively and simply. Built-in support for regular expressions throughout, web service calls, remote script execution, and parallel and asynchronous jobs and lots and lots of libraries for all kinds of things.

    Seriously, I know its popular and often-deserved to hate on Microsoft but PowerShell is a kick-ass, cross-platform, open-source, modern shell done right, even if it does have a dumb name imo. Once you start learning it you won’t want to go back to any other.

  • zygo_histo_morpheus@programming.dev
    link
    fedilink
    arrow-up
    1
    ·
    3 months ago

    Looking at the example

    Why does the generated bash look like that? Is this more safe somehow than a more straighforward bash if or does it just generate needlessly complicated bash?

  • yetAnotherUser@lemmy.ca
    link
    fedilink
    arrow-up
    0
    ·
    3 months ago

    I checked the docs, and I’m a bit confused with one thing. They show that you can capture the stdout of a command into a variabe, but they never show stderr being captured. How would that work?

    • syd@lemy.lolOP
      link
      fedilink
      arrow-up
      0
      arrow-down
      1
      ·
      3 months ago

      Like this: ‘’’ $mv file.txt dest.txt$ failed { echo “It seems that the file.txt does not exist” } ‘’’

      • yetAnotherUser@lemmy.ca
        link
        fedilink
        arrow-up
        1
        ·
        3 months ago

        Knowing if a command failed and capturing stderr (which contains stuff like error messages) are not the same thing.