this post was submitted on 21 May 2024
1 points (100.0% liked)

Programming

17326 readers
231 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS
 

New favorite tool ๐Ÿ˜

top 17 comments
sorted by: hot top controversial new old
[โ€“] zygo_histo_morpheus@programming.dev 1 points 5 months ago (1 children)

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?

[โ€“] dyc3@lemmy.world 1 points 5 months ago

Yeah that shit is completely unreadable

[โ€“] ReluctantMuskrat@lemmy.world 1 points 5 months ago (2 children)

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.

[โ€“] caseyweederman@lemmy.ca 1 points 5 months ago

I appreciate you sharing your perspective. Mine runs counter to it.
The more PowerShell I learn, the more I dislike it.

[โ€“] jelloeater85@lemmy.world 0 points 5 months ago (1 children)
[โ€“] ReluctantMuskrat@lemmy.world 1 points 5 months ago

I do. Currently I use it mostly for personal stuff as part of my time spent on production support. Importing data from queries, exporting spreadsheets, reading complex json data and extracting needed info, etc. In the past when I was on DevOps used it with Jenkins and various automation processes, and I've used it as a developer to create test environments and test data.

[โ€“] eveninghere@beehaw.org 0 points 5 months ago (1 children)

Why not compile it to sh though.

[โ€“] jack@monero.town 0 points 5 months ago* (last edited 5 months ago) (1 children)

There is no sh shell. /bin/sh is just a symlink to bash or dash or zsh etc.

But yes, the question is valid why it compiles specifically to bash and not something posix-compliant

[โ€“] emptiestplace@lemmy.ml 1 points 5 months ago

There is no sh shell.

lol

[โ€“] Thcdenton@lemmy.world 0 points 5 months ago (1 children)

There's a joke here but I'm not clever enough to make it.

[โ€“] driving_crooner@lemmy.eco.br 1 points 5 months ago

Pretty cool bug. Looks like a surreal meme

[โ€“] thingsiplay@beehaw.org 0 points 5 months ago* (last edited 5 months ago) (1 children)

Basically another shell scripting language. But unlike most other languages like Csh or Fish, it can compile back to Bash. At the moment I am bit conflicted, but the thing it can compile back to Bash is what is very interesting. I'll keep an eye on this. But it makes the produced Bash code a bit less readable than a handwritten one, if that is the end goal.

curl -s "https://raw.githubusercontent.com/Ph0enixKM/AmberNative/master/setup/install.sh" | $(echo /bin/bash)

I wish this nonsense of piping a shell script from the internet directly into Bash would stop. It's a bad idea, because of security concerns. This install.sh script eval and will even run curl itself to download amber and install it from this url

url="https://github.com/Ph0enixKM/${__0_name}/releases/download/${__2_tag}/amber_${os}_${arch}" ... echo "Please make sure that root user can access /opt directory.";

And all of this while requiring root access.

I am not a fan of this kind of distribution and installation. Why not provide a normal manual installation process and link to the projects releases page: https://github.com/Ph0enixKM/Amber/releases BTW its a Rust application. So one could build it with Cargo, for those who have it installed.

[โ€“] eveninghere@beehaw.org 0 points 5 months ago (1 children)

I mean, you can always just download the script, investigate it yourself, and run it locally. I'd even argue it's actually better than most installers.

[โ€“] 30p87@feddit.de 0 points 5 months ago* (last edited 5 months ago)

Install scripts are just the Linux versions of installer exes. Hard and annoying to read, probably deviating from standard behaviour, not documenting everything, probably being bound to specific distros and standards without checks, assuming stuff way too many times.

[โ€“] yetAnotherUser@lemmy.ca 0 points 5 months ago (1 children)

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.lol -1 points 5 months ago (1 children)

Like this: โ€˜โ€™โ€™ $mv file.txt dest.txt$ failed { echo "It seems that the file.txt does not exist" } โ€˜โ€™โ€™

[โ€“] yetAnotherUser@lemmy.ca 1 points 5 months ago

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