Bash scripts / alternatives (off-topic posts)

Are you pulling my leg? Even Perl is more succinct & readable :laughing:

Bash scripts, especially when utilizing pipes, are really hard to beat for certain types of operations.

Whether those use cases apply to edeliver is another conversation entirely, but don’t knock Bash.

2 Likes

Yeah, definitely Bash pipes are cool. But it’s only a way to call other programs. When you start to write code in Bash, things getting much worse very soon. And Edeliver code is not an exception. For example, try to figure out how to make Edeliver to set Erlang and Elixir versions on the build server through kerl & kiex, and you will get what I mean.

3 Likes

I’m not going to advocate for doing anything particularly complex with it, don’t get me wrong there. :slight_smile: Just depending on the situation, it can be great.

1 Like

Perl often looks like line noise. :wink:

Now I like perl, can do magic in that language (it was the best thing on the old SCO Unix servers I managed), but the fact things like the ‘types’ of things change based on things like hidden context is crazy. :wink:

+1

Or ZSH, ZSH is a more ‘sane’ bash in how it handles expansions and all, but is mostly identical. ^.^

Why doesn’t it just use docker for the builds and deployment, or asdf or so? Deploying with docker is sooo simple and you don’t have to worry about platform-specific oddities.

/me hasn’t used Edeliver as just deploys via rsync and a systemd script

1 Like

I guess we shouldn’t muddle up Bash as a programming language, and as a shell. Although they are highly coupled, but in any case


What’s the difference between asdf & kiex usage? In general your question looks like “Why do we need Edeliver?”, but it’s a bit odd question for the topic about Edeliver :sweat_smile:

2 Likes

asdf actually wraps kerl (among other things) to give a simple interface for integrating all of those (and a lot more things), and having it acquire and globally or locally set the versions is pretty trivial (even more so in docker, but you don’t need any management thing if using docker, it should just deploy using docker). :slight_smile:

But a big thing if deploying on the base OS is that you can set an erlang/elixir version local and specific to a given directory tree. :slight_smile:

No problems with BASH itself - it’s a tool as much as Elixir. It’s just happened that BASH became a maintanance nightmare because it’s not covered with tests and almost none is interested in learning it, including myself. It might be good in situations when there would be a person who will look after it but it’s not a case here.

2 Likes

Bash is a DSL for calling other programs. Edeliver was originally written in bash because calling other programs is mostly what it does (but the logic just got gradually more convoluted, so it isn’t just calling other programs anymore, so it needs better).

If I was God-Emperor of the world, I’d use PowerShell But On The BEAM Instead Of .NET. Administrative stuff would work like this:

$application = "myapp"
$version = "1.0.3"
$servers = "server1.localdomain","server2.localdomain"
$directory = "path/to/release"
$releaseFilename = "$application-$version.tar.gz" 
$releaseContents = Get-Content $releaseFilename
$username = "notriddle"
$servers | foreach {
  Invoke-Command -ComputerName $_ -Credential $username -ScriptBlock {
    cd $directory
    Set-Content -path $releaseFilename -value $releaseContents
    tar -xvf $releaseFilename # notice how I can just call "tar" like this and it just works
    ./bin/$application upgrade
  }
}

Yes, it’s the unholy offspring of bash, Perl, and C#. I love it anyway.

It has all the conceptual gunk already there for calling into other applications easily (calling a command in PowerShell will consult the $Env:PATH and produce a pipeable stream split by lines, just like bash does) while simultaneously allowing you to have actual manipulatable thingies like lists ($servers is a list, which is a stream in PowerShell just like lists are streams in Elixir) and PID’s (not demonstrated here, because we’re not really doing anything that needs it, but it could be done).

I’m not sure if writing a PowerShell → Core Erlang compiler would be the absolute best possible use of our time, though


1 Like

I guess with a good unit and integration tests coverage it can be pretty much any scripting language :slight_smile:

But so far I found Bootleg’s approach the best - a bunch of mix tasks and sshkit.ex

1 Like