From 3349cbaf77d07fc70f6556e4b43b8c5bf737234f Mon Sep 17 00:00:00 2001 From: frizzus Date: Wed, 30 Apr 2025 23:13:11 +0200 Subject: [PATCH] if a directory where should be located a shell configuration does not exists, create it --- scripts/install-multi-user.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/install-multi-user.sh b/scripts/install-multi-user.sh index f051ccc46..a9685bfaf 100644 --- a/scripts/install-multi-user.sh +++ b/scripts/install-multi-user.sh @@ -888,12 +888,15 @@ configure_shell_profile() { _sudo "to back up your current $profile_target to $profile_target$PROFILE_BACKUP_SUFFIX" \ cp "$profile_target" "$profile_target$PROFILE_BACKUP_SUFFIX" else - # try to create the file if its directory exists + # try to create the file + # If the directory does not exists, create it target_dir="$(dirname "$profile_target")" - if [ -d "$target_dir" ]; then - _sudo "to create a stub $profile_target which will be updated" \ - touch "$profile_target" + if [ ! -d "$target_dir" ]; then + _sudo "to create the $target_dir directory which is missing" \ + mkdir -p "$target_dir" fi + _sudo "to create a stub $profile_target which will be updated" \ + touch "$profile_target" fi if [ -e "$profile_target" ]; then