I have some bash scripts, one which has the following content:#!/bin/bashsource $(dirname ${BASH_SOURCE[0]})/script.shwhile the other one has the following content:#!/bin/bashsource $(dirname ${BASH_SOURCE[0]})/script.shHow do these scripts behave differently and why? What is the difference?
What is the difference having double quotes or not in bash
bash;shell;quoting
The main difference is that the quoted version is not subject to field splitting by the shell. With double quotes the outcome of the command expansion would be fed as one parameter to the source command. Without quotes it would be broken up into multiple parameters, depending on the value of IFS which contains space, TAB and newline by default. If the directory name does not contain such spaces then field splitting does not occur.As a rule of thumb, it is best to use double quotes with command substitutions and variable expansions.