Bash Icon

Bash

Bash is a shell and command language interpreter for the GNU operating system.
16 Stories
All Topics

Ryan Palo assertnotmagic.com

Short circuiting in Bash

Learn from Ryan Palo about the super-powers of the “short-circuit” policy in Bash. In Bash, the && and || (AND and OR) operators work via a “short-circuit” policy. if [[ "$1" -gt 5 ]] && [[ "$1" -lt 10 ]]; then This checks the first condition. If the first condition is true, then there’s a possibility the whole thing could be true, so it checks the second condition. If the second condition is true, then the whole thing is true! However, if the first condition is false, then there’s no reason to check the second condition, because the whole thing could never possibly be true with the first one false.

read more

Daniel Weibel itnext.io

macOS uses a completely outdated version of Bash

This post from Daniel Weibel not only explains how macOS uses an outdated version of Bash, but also how to upgrade to the latest Bash via Homebrew. One thing that many macOS users don’t know is that they are using a completely outdated version of the Bash shell. However, it is highly recommended to use a newer version of Bash on macOS, because it enables you to use useful new features. $ bash --version GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18) Copyright (C) 2007 Free Software Foundation, Inc. The reason Apple uses this old version of Bash has to do with licensing. Bash 4.0 and newer uses the GNU General Public License v3 (GPLv3), which Apple doesn’t support. There are some discussions about this on Reddit. Version 3.2 of GNU Bash is the last version with a license that Apple is willing to accept, and so it sticks with it.

read more

Bash github.com

A standard library and boilerplate framework for writing tools using Bash

The aim of Bash Infinity is to maximize readability of bash scripts, minimize the amount of code repeat and create a central repository for a well-written, and a well-tested standard library for bash. It seems to me that by the time you need something as fancy/full-featured as this, maybe the task at hand has outgrown Bash? Cool, nonetheless. 👍

read more

Bash github.com

A command-line system information tool written in bash 3.2+

The overall purpose of Neofetch is to be used in screen-shots of your system. Neofetch shows the information other people want to see. There are other tools available for proper system statistic/diagnostics. Supports almost 150 different operating systems, so odds are it has you covered. Check my results below. Pretty decent uptime for a laptop, no?

read more

Bash github.com

A collection of pure bash alternatives to external processes

The goal of this repository is to document known and unknown methods of doing various tasks using only built-in bash features. Using the snippets from this guide can help to remove unneeded dependencies from your scripts and in most cases make them that little bit faster. I often start out with a bash script, but as soon as things get complicated I ditch it for Ruby. With this collection in hand, perhaps I can get a bit more done without throwing the baby out with the bash water.

read more

Lazarus Lazaridis iridakos.com

How to create a bash completion script

A tutorial for adding bash completion to scripts using the bash programmable completion facilities. Why bother? to save users from typing text when it can be auto-completed to help users know what are the available continuations to their commands to prevent errors and improve their experience by hiding or showing options based on what users have already typed I’m a tab-completion junkie, so the more people that know how to do this, the better!

read more

0:00 / 0:00