mirror of
https://github.com/nix-community/impermanence
synced 2024-11-10 05:44:17 +00:00
mount-file.bash: be quieter when debugging is off
This commit is contained in:
parent
def994adbd
commit
32a5793139
1 changed files with 7 additions and 2 deletions
|
@ -19,14 +19,19 @@ mountPoint="$1"
|
||||||
targetFile="$2"
|
targetFile="$2"
|
||||||
debug="$3"
|
debug="$3"
|
||||||
|
|
||||||
|
trace() {
|
||||||
|
if (( "$debug" )); then
|
||||||
|
echo "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
if (( "$debug" )); then
|
if (( "$debug" )); then
|
||||||
set -o xtrace
|
set -o xtrace
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -L "$mountPoint" && $(readlink -f "$mountPoint") == "$targetFile" ]]; then
|
if [[ -L "$mountPoint" && $(readlink -f "$mountPoint") == "$targetFile" ]]; then
|
||||||
echo "$mountPoint already links to $targetFile, ignoring"
|
trace "$mountPoint already links to $targetFile, ignoring"
|
||||||
elif mount | grep -F "$mountPoint"' ' >/dev/null && ! mount | grep -F "$mountPoint"/ >/dev/null; then
|
elif mount | grep -F "$mountPoint"' ' >/dev/null && ! mount | grep -F "$mountPoint"/ >/dev/null; then
|
||||||
echo "mount already exists at $mountPoint, ignoring"
|
trace "mount already exists at $mountPoint, ignoring"
|
||||||
elif [[ -e "$mountPoint" ]]; then
|
elif [[ -e "$mountPoint" ]]; then
|
||||||
echo "A file already exists at $mountPoint!" >&2
|
echo "A file already exists at $mountPoint!" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Reference in a new issue