Created
September 23, 2020 15:07
-
-
Save maxamillion/67e4cd0da5553f8d2c98a26ae40206dc to your computer and use it in GitHub Desktop.
gnu readarray example (works on bash 4.4+, requires new delimiter param for builtin readarray)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# local_clone_destination_dir my_fork_or_repo [upstream_repo] | |
mkdir -p /tmp/symlinks | |
symlinks_src_dest=( | |
"/tmp/foo /tmp/symlinks/foo" | |
"/tmp/bar /tmp/symlinks/bar" | |
) | |
for symlink in "${symlinks_src_dest[@]}" | |
do | |
# Read in the string from symlinks_src_dest | |
readarray -d ' ' src_dest_string_split <<< "${symlink}" | |
# Make sure the src exists | |
touch "${src_dest_string_split[0]}" | |
# Create the symlink if the destination symlink does not exist | |
if ! [[ -h "${src_dest_string_split[1]}" ]]; then | |
ln -s "${src_dest_string_split[0]}" "${src_dest_string_split[1]}" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment