Skip to content

Commit

Permalink
assemble: fix empty args in hooks handling
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Di Maio <[email protected]>
  • Loading branch information
89luca89 committed Nov 19, 2023
1 parent b6e2073 commit cca85a2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions distrobox-assemble
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ run_distrobox() (
args=": ;"
separator=""
for arg in ${init_hooks}; do
if [ -z "${arg}" ]; then
continue
fi

args="${args} ${separator} ${arg}"

# Prepare for the next line, if we already have a ';' or '&&', do nothing
Expand All @@ -309,12 +313,16 @@ run_distrobox() (
args=": ;"
separator=""
for arg in ${pre_init_hooks}; do
if [ -z "${arg}" ]; then
continue
fi

args="${args} ${separator} ${arg}"

# Prepare for the next line, if we already have a ';' or '&&', do nothing
# else prefer adding '&&'
if ! echo "${arg}" | grep -q ';[[:space:]]\{0,1\}$' &&
! echo "${arg}" | grep -q '&&[[:space:]]\{0,1\}$'; then
if ! echo "${arg}" | grep -E ';[[:space:]]\{0,1\}$' &&
! echo "${arg}" | grep -E '&&[[:space:]]\{0,1\}$'; then
separator="&&"
else
separator=""
Expand Down

0 comments on commit cca85a2

Please sign in to comment.