Install Shellharden on Ubuntu 24.04

Install Shellharden on Ubuntu 24.04

Shellharden is a syntax highlighter and a tool designed to assist in semi-automating the rewriting of shell scripts to conform with ShellCheck guidelines. This tutorial demonstrates how to install Shellharden on Ubuntu 24.04.

Install Shellharden

Download Shellharden archive file:

wget -qO shellharden.tar.gz https://github.com/anordal/shellharden/releases/latest/download/shellharden-x86_64-unknown-linux-gnu.tar.gz

Extract executable to /usr/local/bin directory:

sudo tar xf shellharden.tar.gz -C /usr/local/bin shellharden

To verify the version of Shellharden, use the following command:

shellharden --version

Remove unneeded archive file:

rm -rf shellharden.tar.gz

Testing Shellharden

Create Bash script for testing purposes:

nano test.sh

Add the following code:

#!/bin/bash

test="Hello world"
echo $test

To use Shellharden, simply run the command shellharden followed by the name of the Bash script:

shellharden test.sh

The default mode operates similarly to cat, but with syntax highlighting in foreground colors and suggested changes displayed in background colors. In our case, Shellharden suggests adding quotes around the variable:

#!/bin/bash

test="Hello world"
echo "$test"

Uninstall Shellharden

To fully uninstall Shellharden, simply remove the executable:

sudo rm -rf /usr/local/bin/shellharden

Leave a Comment

Cancel reply

Your email address will not be published.