Skip to content

Commit

Permalink
πŸ› Add creation of target parent folder in create_symbolic_links.sh
Browse files Browse the repository at this point in the history
In the script for creating symbolic links, a line was added to create the parent directory of the target file, if it does not exist already. This is to prevent errors when trying to create a symbolic link where the target folder path does not exist yet. The folder creation step is added to both 'if' and 'elif' conditions to handle all possible cases.
  • Loading branch information
wingy3181 committed Nov 29, 2023
1 parent 07677cf commit 659d271
Show file tree
Hide file tree
Showing 24 changed files with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/os/create_symbolic_links.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,18 @@ create_symlinks() {
# using regex '.*\/\(.*\)' and replacing topic folder with its contents
# For example, 'shell/bash_aliases' to 'bash_aliases'
targetFile="$HOME/.$(printf "%s" "$i" | sed "s/[^\/]*\/\(.*\)/\1/g")"
targetFolder="$(printf "%s" "$targetFile" | sed "s|/[^/]*$||")"

if [ "$(readlink "$targetFile")" == "$sourceFile" ]; then

print_success "$targetFile β†’ $sourceFile"

elif [ ! -e "$targetFile" ] || $skipQuestions; then # -e : True if file exists (regardless of type).

if [ "$targetFolder" != "$HOME" ]; then
mkdir -p "$targetFolder"
fi

execute_without_spinner \
"ln -fs $sourceFile $targetFile" \
"$targetFile β†’ $sourceFile"
Expand All @@ -91,6 +96,10 @@ create_symlinks() {

rm -rf "$targetFile"

if [ "$targetFolder" != "$HOME" ]; then
mkdir -p "$targetFolder"
fi

execute_without_spinner \
"ln -fs $sourceFile $targetFile" \
"$targetFile β†’ $sourceFile"
Expand Down
Empty file modified src/os/installs/macos/android_tools.sh
100644 β†’ 100755
Empty file.
Empty file modified src/os/installs/macos/browsers.sh
100644 β†’ 100755
Empty file.
Empty file modified src/os/installs/macos/capture_tools.sh
100644 β†’ 100755
Empty file.
Empty file modified src/os/installs/macos/cli_utilities.sh
100644 β†’ 100755
Empty file.
Empty file modified src/os/installs/macos/communication_tools.sh
100644 β†’ 100755
Empty file.
Empty file modified src/os/installs/macos/compression_tools.sh
100644 β†’ 100755
Empty file.
Empty file modified src/os/installs/macos/desktop_utilities.sh
100644 β†’ 100755
Empty file.
Empty file modified src/os/installs/macos/development_tools.sh
100644 β†’ 100755
Empty file.
Empty file modified src/os/installs/macos/downloaders.sh
100644 β†’ 100755
Empty file.
Empty file modified src/os/installs/macos/gaming.sh
100644 β†’ 100755
Empty file.
Empty file modified src/os/installs/macos/git.sh
100644 β†’ 100755
Empty file.
Empty file modified src/os/installs/macos/image_tools.sh
100644 β†’ 100755
Empty file.
Empty file modified src/os/installs/macos/misc_tools.sh
100644 β†’ 100755
Empty file.
Empty file modified src/os/installs/macos/music.sh
100644 β†’ 100755
Empty file.
Empty file modified src/os/installs/macos/networking_tools.sh
100644 β†’ 100755
Empty file.
Empty file modified src/os/installs/macos/office_tools.sh
100644 β†’ 100755
Empty file.
Empty file modified src/os/installs/macos/remote_access_tools.sh
100644 β†’ 100755
Empty file.
Empty file modified src/os/installs/macos/system_tools.sh
100644 β†’ 100755
Empty file.
Empty file modified src/os/installs/macos/tmux.sh
100644 β†’ 100755
Empty file.
Empty file modified src/os/installs/macos/video_tools.sh
100644 β†’ 100755
Empty file.
Empty file modified src/os/installs/macos/vim.sh
100644 β†’ 100755
Empty file.
Empty file modified src/os/installs/macos/virtualisation_tools.sh
100644 β†’ 100755
Empty file.
Empty file modified src/os/installs/macos/web_font_tools.sh
100644 β†’ 100755
Empty file.

0 comments on commit 659d271

Please sign in to comment.