Share your favorite scripts

Hello

I couldn’t comment on the GitLab snippet so I’ll comment here.

I never studied POSIX but I’m quite fluent in Bash. Photo Funnel is called pf.sh which means it’s a shell script, but the header tries to load the Bash executable, #!/bin/bash If there is a Bash-compliant shell installed but its not called Bash and there is no symlink from /bin/bash to it, the script will fail. The script otherwise looks POSIX-compliant, but as I haven’t studied POSIX I’m unable to say that with certainty. As such, you can either change the header to #!/usr/bin/env bash and change the rest of the script to actually use Bash (replace [ ... "$foo" ] with [[ ... $foo ]] see BashGuide/TestsAndConditionals - Greg's Wiki ), or change the header to #!/bin/sh to use POSIX shell.

This dir='~/backup' is potentially dangerous. It should be dir='$HOME/backup as ~ won’t expand.

f=\…`(ignore the backslashes) should bef=$(…)`

cp $f "$dir" should be cp "$f" "$dir"

2 Likes