---
title: "💭 Safer Bash Shebang Recipes - Just Programmer's Manual"
description: "!https://just.systems/man/en/safer-bash-shebang-recipes.html?highlight=pipefail#safer-bash-shebang-recipes"
date: 2024-05-14
published: true
tags:
  - just
  - justfile
  - thought
template: link
---


<div class="embed-card embed-card-external">
  <a href="https://just.systems/man/en/safer-bash-shebang-recipes.html?highlight=pipefail#safer-bash-shebang-recipes" class="embed-card-link" target="_blank" rel="noopener noreferrer">
    <div class="embed-card-content">
      <div class="embed-card-title">Safer Bash Shebang Recipes - Just Programmer&#39;s Manual</div>
      <div class="embed-card-meta">just.systems</div>
    </div>
  </a>
</div>


When using justfiles each line is ran separately from the last, unless you specify the file to be ran by something other than just such as bash.  If you want variables to persist you need to set a shebang.

Also if you are using your script i a way that you want it to exit when it fails you need to set -e and  -o pipefail.  This is critical if you are thinking about using just for production scripts like ci/cd.  I've hit too bugs where ci passes, but no artifacts were created issues for this exact reason.

``` bash
foo:
  #!/usr/bin/env bash
  set -euxo pipefail
  hello='Yo'
  echo "$hello from Bash!"
```

!!! note

    This post is a <a href="/thoughts/" class="wikilink" data-title="Thoughts" data-description="These are generally my thoughts on a web page or some sort of url, except a rare few don&#39;t have a link. These are dual published off of my..." data-date="2024-04-01">thought</a>. It's a short note that I make
    about someone else's content online <a href="/tags/thoughts/" class="hashtag-tag" data-tag="thoughts" data-count=2 data-reading-time=3 data-reading-time-text="3 minutes">#thoughts</a>
