I’m trying to understand a bash script whose first four lines are:
#!/bin/sh
SCRIPT="`basename $0 | sed 's/\..*$//'`"
CONFIG=${1:-$HOME/.$SCRIPT}
DIR=${2:-$HOME/Documents}
I understand that the last two lines are doing parameter substitution on paths input as script arguments 1 and 2, but I’ve been unable to figure out how this works (e.g. here). What does the “:-” part mean? Sorry for the newbie question.
From
man bash:Very easy to find, with
man bash, and then /:-. The slash introduces a search, and:-is just the content to search for. Else, searching in bash can get very boring, because it is huge, but here it is the first hit.